Changes in the Cache

When you use an Extent for the set of candidate instances in a query, the instances you retrieve depend on the setting of the IgnoreCache flag. This flag indicates whether changes you have made to instances during the transaction should be reflected in the query results.

If IgnoreCache is false, instances that were made persistent in the current transaction are included in the set of candidate instances; instances deleted in the current transaction are not included in the set of candidate instances. Furthermore, instances changed in the transaction are evaluated with their current values.

Setting IgnoreCache to true tells the query engine that you would like queries to be optimized and to return approximate results by ignoring any changes in the cache. Instances made persistent in the current transaction might not be considered part of the candidate instances, and instances deleted in the current transaction might not be considered part of the candidate instances.

For portability, you should set the IgnoreCache flag to false. An implementation may choose to ignore the setting of the IgnoreCache flag, always returning exact results that reflect current cached values, just as if the value of the flag were false. The results of iterating Extents and executing queries may differ among implementations when IgnoreCache is set to true.

The PersistenceManager interface has the following methods to get and set the value of the IgnoreCache flag for all Query instances ...

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.