Annotation Interface QueryOptions
Configures options that affect the execution of a query. This annotation may be applied to:
- a method with a
JakartaQueryor Jakarta Datajakarta.data.repository.Queryannotation, - a method with a
NativeQueryannotation, - a Jakarta Data repository method annotated
jakarta.data.repository.Deletethat uses the parameter-based automatic query pattern, or - a Jakarta Data repository method annotated
jakarta.data.repository.Find.
This annotation must be respected by an implementation of Jakarta Data backed by Jakarta Persistence.
- Since:
- 4.0
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe cache retrieve mode to use.The cache store mode to use.The name of aNamedEntityGraphapplied to the entity returned by the query.The query flush mode to use when executing the query.Query properties and hints.The lock mode type to use in query execution.The pessimistic lock scope to use in query execution if a pessimistic lock mode is specified vialockMode().intA query timeout in milliseconds.
-
Element Details
-
cacheStoreMode
CacheStoreMode cacheStoreModeThe cache store mode to use. The presence of this annotation overrides the default cache store mode of the persistence context.This option applies when the query is a JPQL
selectquery or a native query that returns a result set.- See Also:
- Default:
USE
-
cacheRetrieveMode
CacheRetrieveMode cacheRetrieveModeThe cache retrieve mode to use. The presence of this annotation overrides the default cache retrieve mode of the persistence context.This option applies when the query is a JPQL
selectquery or a native query that returns a result set.- See Also:
- Default:
USE
-
timeout
int timeoutA query timeout in milliseconds. By default, there is no timeout.- See Also:
- Default:
-1
-
hints
QueryHint[] hintsQuery properties and hints. May include vendor-specific query hints.- See Also:
- Default:
{}
-
lockMode
LockModeType lockModeThe lock mode type to use in query execution. If alockModeother thanLockModeType.NONEis specified, the query must be executed in a transaction and the persistence context joined to the transaction.If a lock mode is explicitly specified for a native query, the behavior is undefined and unportable between persistence providers.
This option applies when the query is a JPQL
selectquery or a native query that returns a result set.- See Also:
- Default:
NONE
-
lockScope
PessimisticLockScope lockScopeThe pessimistic lock scope to use in query execution if a pessimistic lock mode is specified vialockMode().This option applies when the query is a JPQL
selectquery or a native query that returns a result set.- Default:
NORMAL
-
entityGraph
String entityGraphThe name of aNamedEntityGraphapplied to the entity returned by the query. By default, no entity graph is applied. The named entity graph must be an entity graph compatible with the entity type returned by the query. If the result type of the query is not an entity type, the behavior is undefined. The entity graph is interpreted as a load graph. The entity graph specified here may be overridden by callingsetEntityGraph().This option applies when the query is a JPQL
select.- See Also:
- Default:
""
-
flush
QueryFlushMode flushThe query flush mode to use when executing the query.- See Also:
- Default:
DEFAULT
-