Java Code Examples for javax.jdo.Query#executeList()
The following examples show how to use
javax.jdo.Query#executeList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryManager.java From dependency-track with Apache License 2.0 | 6 votes |
/** * Returns a List of Finding objects for the specified project. * @param project the project to retrieve findings for * @return a List of Finding objects */ @SuppressWarnings("unchecked") public List<Finding> getFindings(Project project) { final Query query = pm.newQuery(JDOQuery.SQL_QUERY_LANGUAGE, Finding.QUERY); query.setParameters(project.getId()); final List<Object[]> list = query.executeList(); final List<Finding> findings = new ArrayList<>(); for (final Object[] o: list) { final Finding finding = new Finding(project.getUuid(), o); final Component component = getObjectByUuid(Component.class, (String)finding.getComponent().get("uuid")); final Vulnerability vulnerability = getObjectByUuid(Vulnerability.class, (String)finding.getVulnerability().get("uuid")); final Analysis analysis = getAnalysis(null, component, vulnerability); if (analysis == null || !analysis.isSuppressed()) { // do not add globally suppressed findings // These are CLOB fields. Handle these here so that database-specific deserialization doesn't need to be performed (in Finding) finding.getVulnerability().put("description", vulnerability.getDescription()); finding.getVulnerability().put("recommendation", vulnerability.getRecommendation()); findings.add(finding); } } return findings; }
Example 2
Source File: GuideToJDO.java From tutorials with MIT License | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public void QuerySQL() { PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null); PersistenceManager pm = pmf.getPersistenceManager(); Transaction tx = pm.currentTransaction(); try { tx.begin(); // SQL : LOGGER.log(Level.INFO, "SQL --------------------------------------------------------------"); Query query = pm.newQuery("javax.jdo.query.SQL", "SELECT * FROM PRODUCT"); query.setClass(Product.class); List<Product> results = query.executeList(); Iterator<Product> iter = results.iterator(); while (iter.hasNext()) { Product p = iter.next(); LOGGER.log(Level.WARNING, "Product name: {0} - Price: {1}", new Object[] { p.name, p.price }); } LOGGER.log(Level.INFO, "--------------------------------------------------------------"); tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } pm.close(); } }
Example 3
Source File: MyApp.java From tutorials with MIT License | 5 votes |
public static void queryUsingSQL() { Query query = pm.newQuery("javax.jdo.query.SQL", "select * from " + "product_item where price < ? and status = ?"); query.setClass(ProductItem.class); query.setParameters(10, "InStock"); List<ProductItem> results = query.executeList(); }
Example 4
Source File: MyApp.java From tutorials with MIT License | 4 votes |
public static void namedQuery() { Query<ProductItem> query = pm.newNamedQuery(ProductItem.class, "PriceBelow10"); List<ProductItem> results = query.executeList(); }