8.4. Query examples

Although we have yet to discuss the syntax of query filters, we are now in a position to examine some simple queries.

8.4.1. Query without filter

Our first example is a query that lists all instances of the BusinessPartner class. I have presented this as a small application with a main() method which can be run from the command line, although future query examples will be shown as code snippets.

SimpleQuery.Java
 package com.ogilviepartners.jdobook.app; import java.util.Collection; import java.util.Iterator; import javax.jdo.*; public class SimpleQuery { public static void main() { JDOBootstrap bootstrap = new JDOBootstrap(); PersistenceManagerFactory pmf = bootstrap.getPersistenceManagerFactory(); PersistenceManager pm = ...

Get Java™ Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.