JDO defines ways of querying objects persisted into the datastore. It provides its own object-based
query language (JDOQL). JDOQL is designed as the Java developers way of having the power of SQL
queries, yet retaining the Java object relationship that exist in their application model. DataNucleus
provides all functionality required by the JDO 1.0 and 2.0 specifications as well as providing a
series of vendor extensions. A typical JDOQL query may be set up in one of 2 ways. Here's an example

So here in our example we select all "Person" objects with surname of "Jones" and where the persons
age is below 20. The language is intuitive for Java developers, and is intended as their interface
to accessing the persisted data model. As can be seen above, the query is made up of distinct parts.
The class being selected (the SELECT clause in SQL), the filter (which equates to the WHERE clause
in SQL), together with any sorting (the ORDER BY clause in SQL), etc.

In traditional (declarative) JDOQL (JDO 1.0) it was necessary to specify the component parts
(filter, candidate class, ordering, etc) of the query using the mutator methods on the Query.
In JDO 2 you can now specify it all in a single string. This string has to follow a particular
pattern, but provides the convenience that many people have been asking for.
The pattern to use is as follows

So this will find all products that include a tax percentage less than some "BAND A" level.
Where you are using "public static final" fields you can either fully-qualify the class name
or you can include it in the "imports" section of the query (see later).

With a query you can pass values into the query as parameters. If you declare the parameters
when defining the query then these are
explicit
parameters, so you set the type of the
parameter, and when you pass the value in it has to be of that type.

Here's a simple example for finding the elements of a class with a field below a particular
threshold level. Here we pass in the threshold value (
limit
)

With a query you can pass values into the query as parameters. If you don't declare the
parameters when defining the query but instead prefix identifiers in the query with
:
(colon) then these are
implicit
parameters.

Let's repeat the previous query but this time using
implicit
parameters.

JDOQL allows the Java keyword
instanceof
so you can compare objects against a class.

Let's take an example. We have a class A that has a field "b" of type B and B has subclasses
B1, B2, B3. Clearly the field "b" of A can be of type B, B1, B2, B3 etc, and we want to find
all objects of type A that have the field "b" that is of type B2. We do it like this