The typical use of a JDOQL query is to translate it into the native query language of the datastore and return objects matched by the query. Sometimes you want to query over a set of objects that you have to hand, or for some datastores it is simply impossible to support the full JDOQL syntax in the datastore native query language . In these situation we need to evaluate the query in-memory . In the latter case of the datastore not supported the full JDOQL syntax we evaluate as much as we can in the datastore and then instantiate those objects and evaluate further in-memory. Here we document the current capabilities of in-memory evaluation in DataNucleus.
To enable evaluation in memory you specify the query extension datanucleus.query.evaluateInMemory to true as follows
This is also useful where you have a Collection of (persisted) objects and want to run a query over the Collection. Simply turn on in-memory evaluation, and supply the candidate collection to the query, and no communication with the datastore will be needed.
With JDO you can define a set of candidate objects that should be queried, rather than just going to the datastore to retrieve those objects. When you specify this you will automatically be switched to evaluate the query in-memory. You set the candidates like this
Query query = pm.newQuery(...); query.setCandidates(myCandidates); List<Product> results = (List<Product>)query.execute();
JDOQL defines support for some methods within its syntax. The following are supported for in-memory evaluation currently.
Support for in-memory evaluation of query methods is provided via a plugin-point so can be extended easily.