Query Caching

JDO doesn't currently define a mechanism for caching of queries. DataNucleus provides the following level of caching

  • Generic Compilation : when a query is compiled it is initially compiled generically into expression trees. This generic compilation is independent of the datastore in use, so can be used for other datastores. This can be cached.


Generic Query Compilation Cache

This cache is by default set to weak , meaning that the generic query compilation is cached using weak references. This is set using the persistence property datanucleus.cache.query.type . You can also set it to hard meaning that strong references are used, or soft meaning that soft references are used, or finally to none meaning that there is no caching of generic query compilation information

You can turn caching on/off (default = on) on a query-by-query basis by specifying the query extension datanucleus.query.cached as true/false.