Annotation Interface QueryOptions


@Target(METHOD) @Retention(RUNTIME) public @interface QueryOptions

Configures options that affect the execution of a query. This annotation may be applied to:

  • a method with a JakartaQuery or Jakarta Data jakarta.data.repository.Query annotation,
  • a method with a NativeQuery annotation,
  • a Jakarta Data repository method annotated jakarta.data.repository.Delete that 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
  • Element Details

    • cacheStoreMode

      CacheStoreMode cacheStoreMode
      The 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 select query or a native query that returns a result set.

      See Also:
      Default:
      USE
    • cacheRetrieveMode

      CacheRetrieveMode cacheRetrieveMode
      The 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 select query or a native query that returns a result set.

      See Also:
      Default:
      USE
    • timeout

      int timeout
      A query timeout in milliseconds. By default, there is no timeout.
      See Also:
      Default:
      -1
    • hints

      QueryHint[] hints
      Query properties and hints. May include vendor-specific query hints.
      See Also:
      Default:
      {}
    • lockMode

      LockModeType lockMode
      The lock mode type to use in query execution. If a lockMode other than LockModeType.NONE is 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 select query or a native query that returns a result set.

      See Also:
      Default:
      NONE
    • lockScope

      The pessimistic lock scope to use in query execution if a pessimistic lock mode is specified via lockMode().

      This option applies when the query is a JPQL select query or a native query that returns a result set.

      Default:
      NORMAL
    • entityGraph

      String entityGraph
      The name of a NamedEntityGraph applied 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 calling setEntityGraph().

      This option applies when the query is a JPQL select.

      See Also:
      Default:
      ""
    • flush

      The query flush mode to use when executing the query.
      See Also:
      Default:
      DEFAULT