DekGenius.com
[ Team LiB ] Previous Section Next Section

9.3 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 created by the PersistenceManager:

boolean getIgnoreCache(  );
void    setIgnoreCache(boolean flag);

The initial value of the IgnoreCache setting in a Query instance is set to the value that the IgnoreCache flag in the PersistenceManager had when the Query was constructed. It is also possible to get and set the IgnoreCache option on a specific Query instance by using the following Query methods:

void    setIgnoreCache(boolean flag);
boolean getIgnoreCache(  );

The IgnoreCache flag is preserved when you construct a query instance from another query instance.

    [ Team LiB ] Previous Section Next Section