Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


maintain-cache

Use eclipselink.maintain-cache to controls whether or not query results are cached in the session cache


Values

Table 4-24 describes this query hint's valid values.

Table 4-24 Valid Values for org.eclipselink.maintain-cache

Value Description

TRUE

Maintain cache.

FALSE

(Default) Do not maintain cache.



Usage

The eclipselink.maintain-cache hint provides a way to query the current database contents without affecting the current persistence context. It configures the query to return un-managed instances so any updates to entities queried using this hint would have to be merged into the persistence context.


Examples

Example 4-48 shows how to use this hint in a JPA query.

Example 4-48 Using maintain-cache in a JPA Query

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint(QueryHints.MAINTAIN_CACHE, HintValues.FALSE);

Example 4-49 shows how to use this hint with the @QueryHint annotation.

Example 4-49 Using maintain-cache in a @QueryHint Annotation

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 @QueryHint(name=QueryHints.MAINTAIN_CACHE, value=HintValues.FALSE);


See Also

For more information, see: