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


read-only

Use eclipselink.read-only to retrieve read-only results back from a query.


Values

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

Table 4-35 Valid Values for read-only

Value Description

TRUE

Retrieve read-only results from the query.

FALSE

(Default) Do not retrieve read-only results from the query.



Usage

For non-transactional read operations, if the requested entity types are stored in the shared cache you can request that the shared instance be returned instead of a detached copy.


NoteNote:

You should never modify objects returned from the shared cache.



Examples

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

Example 4-71 Using read-only in a JPA Query

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint(QueryHints.READ_ONLY, HintValues.TRUE);

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

Example 4-72 Using read-only in a @QueryHint Annotation

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


See Also

For more information, see: