Interface TypedQuery<X>

Type Parameters:
X - query result type
All Superinterfaces:
Query

public interface TypedQuery<X> extends Query
Interface used to control the execution of typed queries. In the Jakarta Persistence query language, only SELECT queries are typed queries, since only a SELECT query can return a result. A DELETE or UPDATE query is not a typed query and is always represented by an untyped instance of Query, usually, by a Statement. On the other hand, a native SQL query is considered a typed query if it returns a result set.
Since:
2.0
See Also:
API note:
Just like any other data access API, including JDBC itself, native SQL query strings and Jakarta Persistence query language strings executed via this API must never be composed by concatenating user input or other untrusted data. User input should be properly validated and passed as a parameter to a parameterized query string. In particular, native SQL query strings executed via this API are typically executed verbatim with no additional validation or sanitization beyond that performed by the JDBC driver.
  • Method Details

    • getResultCount

      long getResultCount()

      Determine the maximum number of results that could in principle be returned by the query if no offset or limit were applied.

      The getResultCount method should not cause query results to be fetched from the database.

      Returns:
      the maximum number of results that could in principle be returned by the query if no offset or limit were applied
      Throws:
      IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement
      QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
      PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
      Since:
      4.0
    • getResultList

      @Nonnull List<X> getResultList()
      Execute the query and return the query results as a typed List<X>. If necessary, first synchronize changes with the database by flushing the persistence context.
      Specified by:
      getResultList in interface Query
      Returns:
      a list of the results, each of type X, or an empty list if there are no results
      Throws:
      IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement
      QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
      TransactionRequiredException - if a lock mode other than NONE has been set and there is no transaction or the persistence context has not been joined to the transaction
      PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
      LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
      PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
      PersistenceException - if the flush fails
      OptimisticLockException - if an optimistic locking conflict is detected during the flush
    • getSingleResult

      X getSingleResult()
      Execute the query, returning a single typed result. If necessary, first synchronize changes with the database by flushing the persistence context.
      Specified by:
      getSingleResult in interface Query
      Returns:
      the result, of type X
      Throws:
      NoResultException - if there is no result
      NonUniqueResultException - if more than one result
      IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement
      QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
      TransactionRequiredException - if a lock mode other than NONE has been set and there is no transaction or the persistence context has not been joined to the transaction
      PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
      LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
      PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
      PersistenceException - if the flush fails
      OptimisticLockException - if an optimistic locking conflict is detected during the flush
    • getResultStream

      @Nonnull default Stream<X> getResultStream()
      Execute the query and return the query results as a typed Stream<X>. If necessary, first synchronize changes with the database by flushing the persistence context.

      By default, this method delegates to getResultList().stream(). The persistence provider may choose to override this method to provide additional capabilities.

      Specified by:
      getResultStream in interface Query
      Returns:
      a stream of the results, each of type X, or an empty stream if there are no results
      Throws:
      IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement
      QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
      TransactionRequiredException - if a lock mode other than NONE has been set and there is no transaction or the persistence context has not been joined to the transaction
      PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
      LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
      PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
      PersistenceException - if the flush fails
      OptimisticLockException - if an optimistic locking conflict is detected during the flush
      Since:
      2.2
      See Also:
    • getSingleResultOrNull

      @Nullable X getSingleResultOrNull()
      Execute the query, returning a single typed result, or null if the query has no results. If necessary, first synchronize changes with the database by flushing the persistence context.
      Specified by:
      getSingleResultOrNull in interface Query
      Returns:
      the result, of type X, or null if there is no result
      Throws:
      NonUniqueResultException - if more than one result
      IllegalStateException - if called for a Jakarta Persistence query language UPDATE or DELETE statement
      QueryTimeoutException - if the query execution exceeds the query timeout value set and only the statement is rolled back
      TransactionRequiredException - if a lock mode other than NONE has been set and there is no transaction or the persistence context has not been joined to the transaction
      PessimisticLockException - if pessimistic locking fails and the transaction is rolled back
      LockTimeoutException - if pessimistic locking fails and only the statement is rolled back
      PersistenceException - if the query execution exceeds the query timeout value set and the transaction is rolled back
      PersistenceException - if the flush fails
      OptimisticLockException - if an optimistic locking conflict is detected during the flush
      Since:
      3.2
    • setMaxResults

      @Nonnull TypedQuery<X> setMaxResults(int maxResult)
      Set the maximum number of results returned to the client. If the query has more results than the given maximum, results are excluded from the list returned by getResultList(), so that only the given number of results is returned. If the query returns results with a well-defined order, the excluded results must be those which would otherwise occur later in the list.
      Specified by:
      setMaxResults in interface Query
      Parameters:
      maxResult - The maximum number of results
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the argument is negative
    • setFirstResult

      @Nonnull TypedQuery<X> setFirstResult(int startPosition)
      Set the position of the first query result returned to the client. The given number of results is excluded from the list returned by getResultList(). If the query returns results with a well-defined order, the excluded results must be those which would otherwise occur earlier in the list.
      Specified by:
      setFirstResult in interface Query
      Parameters:
      startPosition - The position of the first result, numbered from 0
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the argument is negative
    • getMaxResults

      int getMaxResults()
      The maximum number of results returned to the client, as specified by setMaxResults(int), or 2147483647 if setMaxResults(int) was not called.
      Specified by:
      getMaxResults in interface Query
      Returns:
      the maximum number of results
      Since:
      2.0
    • getFirstResult

      int getFirstResult()
      The position of the first result returned to the client, as specified by setFirstResult(int), or 0 if setFirstResult(int) was not called.
      Specified by:
      getFirstResult in interface Query
      Returns:
      the position of the first result
      Since:
      2.0
    • setHint

      @Nonnull TypedQuery<X> setHint(@Nonnull String hintName, @Nullable Object value)
      Set a query property or hint. Properties defined by this specification must be observed by the persistence provider. Vendor-specific hints that are not recognized by a provider must be silently ignored. Portable applications should not rely on the standard timeout hint; depending on the database in use and the locking mechanisms used by the provider, this hint may or may not be observed.
      Specified by:
      setHint in interface Query
      Parameters:
      hintName - The name of the property or hint
      value - The value for the property or hint
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given property or hint name is recognized by the provider, but the second argument is not a legal value for the given property or hint
      API note:
      The use of named hints lacks type safety compared to the use of options.
    • setParameter

      @Nonnull <T> TypedQuery<X> setParameter(@Nonnull Parameter<T> parameter, @Nullable T value)
      Bind an argument to a parameter of this query respresented as a Parameter object.
      Specified by:
      setParameter in interface Query
      Type Parameters:
      T - the parameter type
      Parameters:
      parameter - The parameter object
      value - The argument to the parameter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter does not correspond to a parameter of the query
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(@Nonnull Parameter<Calendar> param, @Nullable Calendar value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Calendar to a Parameter object.
      Specified by:
      setParameter in interface Query
      Parameters:
      param - The parameter object
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter does not correspond to a parameter of the query
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(@Nonnull Parameter<Date> param, @Nullable Date value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Date to a Parameter object.
      Specified by:
      setParameter in interface Query
      Parameters:
      param - The parameter object
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter does not correspond to a parameter of the query
    • setParameter

      @Nonnull TypedQuery<X> setParameter(@Nonnull String name, @Nullable Object value)
      Bind an argument value to a named parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the argument is of incompatible type
    • setParameter

      @Nonnull <P> TypedQuery<X> setParameter(@Nonnull String name, @Nullable P value, @Nonnull Class<P> type)
      Bind an argument value to a named parameter, explicitly specifying the parameter type. This is most useful when the argument might be null.
      var books =
          em.createNativeQuery("select * from books where :limit is null or pub_date > :limit",
                                    Book.class)
              .setParameter("limit", optionalDateLimit, LocalDate.class)
              .getResultList();
      
      Specified by:
      setParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      type - A class object representing the parameter type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setParameter

      @Nonnull <P> TypedQuery<X> setParameter(@Nonnull String name, @Nullable P value, @Nonnull Type<P> type)
      Bind an argument value to a named parameter, explicitly specifying the parameter type. This is most useful when the binding is affected by an attribute converter.
      var amount = MonetaryAmount.of(priceLimit, currency);
      var affordableBooks =
          em.createQuery("from Book where price < :amount", Book.class)
              .setParameter("amount", amount, Book_.price.getType())
              .getResultList();
      
      Specified by:
      setParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      type - The Type of the parameter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setConvertedParameter

      @Nonnull <P> TypedQuery<X> setConvertedParameter(@Nonnull String name, @Nullable P value, @Nonnull Class<? extends AttributeConverter<P,?>> converter)
      Bind an argument value to a named parameter, explicitly specifying an attribute converter to use.
       var amount = MonetaryAmount.of(priceLimit, currency);
       var affordableBooks =
           em.createQuery("from Book where price < :amount", Book.class)
               .setConvertedParameter("amount", amount,
                       MonetaryAmountConverter.class)
               .getResultList();
      
      Specified by:
      setConvertedParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      converter - The class of the attribute converter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(@Nonnull String name, @Nullable Calendar value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Calendar to a named parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the value argument is of incompatible type
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(@Nonnull String name, @Nullable Date value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Date to a named parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      name - The name of the parameter
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the parameter name does not correspond to a parameter of the query, or if the value argument is of incompatible type
    • setParameter

      @Nonnull TypedQuery<X> setParameter(int position, @Nullable Object value)
      Bind an argument value to a positional parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a positional parameter of the query, or if the argument is of incompatible type
    • setParameter

      @Nonnull <P> TypedQuery<X> setParameter(int position, @Nullable P value, @Nonnull Class<P> type)
      Bind an argument value to a positional parameter, explicitly specifying the parameter type. This is most useful when the argument might be null.
      var books =
          em.createNativeQuery("select * from books where ?1 is null or pub_date > ?1",
                                    Book.class)
              .setParameter(1, optionalDateLimit, LocalDate.class)
              .getResultList();
      
      Specified by:
      setParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      type - A class object representing the parameter type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a positional parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setParameter

      @Nonnull <P> TypedQuery<X> setParameter(int position, @Nullable P value, @Nonnull Type<P> type)
      Bind an argument value to a positional parameter, explicitly specifying the parameter type. This is most useful when the binding is affected by an attribute converter.
      var amount = MonetaryAmount.of(priceLimit, currency);
      var affordableBooks =
          em.createQuery("from Book where price < ?1", Book.class)
              .setParameter(1, amount, Book_.price.getType())
              .getResultList();
      
      Specified by:
      setParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      type - The Type of the parameter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a positional parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setConvertedParameter

      @Nonnull <P> TypedQuery<X> setConvertedParameter(int position, @Nullable P value, @Nonnull Class<? extends AttributeConverter<P,?>> converter)
      Bind an argument value to a named parameter, explicitly specifying an attribute converter to use.
       var amount = MonetaryAmount.of(priceLimit, currency);
       var affordableBooks =
           em.createQuery("from Book where price < ?1", Book.class)
               .setConvertedParameter(1, amount,
                       MonetaryAmountConverter.class)
               .getResultList();
      
      Specified by:
      setConvertedParameter in interface Query
      Type Parameters:
      P - the parameter type
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      converter - The class of the attribute converter
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a parameter of the query, or if the argument is of incompatible type
      Since:
      4.0
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(int position, @Nullable Calendar value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Calendar to a positional parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a positional parameter of the query, or if the argument is of incompatible type
    • setParameter

      @Deprecated(since="3.2") @Nonnull TypedQuery<X> setParameter(int position, @Nullable Date value, @Nonnull TemporalType temporalType)
      Deprecated.
      Newly written code should use the date/time types defined in java.time.
      Bind an instance of Date to a positional parameter.
      Specified by:
      setParameter in interface Query
      Parameters:
      position - The parameter position
      value - The argument to the parameter
      temporalType - A temporal type
      Returns:
      the same query instance
      Throws:
      IllegalArgumentException - if the given position does not correspond to a positional parameter of the query, or if the argument is of incompatible type
    • setQueryFlushMode

      @Nonnull TypedQuery<X> setQueryFlushMode(@Nonnull QueryFlushMode flushMode)
      Set the query flush mode to be used when the query is executed. This flush mode overrides the flush mode type of the entity manager.
      Specified by:
      setQueryFlushMode in interface Query
      Parameters:
      flushMode - The new flush mode
      Returns:
      the same query instance
      Since:
      4.0
    • setFlushMode

      @Deprecated(since="4.0") @Nonnull TypedQuery<X> setFlushMode(@Nonnull FlushModeType flushMode)
      Set the flush mode type to be used when the query is executed. This flush mode overrides the flush mode type of the entity manager.
      Specified by:
      setFlushMode in interface Query
      Parameters:
      flushMode - The new flush mode
      Returns:
      the same query instance
    • setLockMode

      @Nonnull TypedQuery<X> setLockMode(@Nonnull LockModeType lockMode)
      Set the lock mode type to use when the query is executed.
      Specified by:
      setLockMode in interface Query
      Parameters:
      lockMode - The new lock mode
      Returns:
      the same query instance
      Throws:
      IllegalStateException - if the query is not a Jakarta Persistence query language SELECT query or a CriteriaQuery
      Since:
      2.0
      See Also:
    • setLockScope

      @Nonnull TypedQuery<X> setLockScope(@Nonnull PessimisticLockScope lockScope)
      Set the pessimistic lock scope to use when the query is executed if a pessimistic lock mode is specified via setLockMode(LockModeType). If the query is executed without a pessimistic lock mode, the pessimistic lock scope has no effect.
      Parameters:
      lockScope - The scope of the pessimistic lock
      Returns:
      the same query instance
      Throws:
      IllegalStateException - if the query is not a Jakarta Persistence query language SELECT query or a CriteriaQuery
      Since:
      4.0
    • getLockMode

      @Nullable LockModeType getLockMode()
      The current lock mode for the query or null if a lock mode has not been set.

      The lock mode affects every entity occurring as an item in the SELECT clause, including entities occurring as arguments to constructors. The effect on association join tables, collection tables, and primary and secondary tables of join fetched entities is determined by the specified lock scope. If no lock scope was explicitly specified, the lock scope defaults to NORMAL.

      If the given lock mode is PESSIMISTIC_READ, PESSIMISTIC_WRITE, or PESSIMISTIC_FORCE_INCREMENT, the lock also affects every entity with an attribute reference occurring in the SELECT clause, except when the attribute reference occurs as an argument to an aggregate function.

      Specified by:
      getLockMode in interface Query
      Returns:
      the current lock mode
      Throws:
      IllegalStateException - if the query is not a Jakarta Persistence query language SELECT query or a CriteriaQuery
      Since:
      2.0
      See Also:
    • getLockScope

      @Nullable PessimisticLockScope getLockScope()
      The current pessimistic lock scope for the query or null if a scope has not been set.

      The lock scope determines the effect of locking on association join tables, collection tables, and primary and secondary tables of join fetched entities. If no lock scope was explicitly specified, locking behaves as if the lock scope were set to NORMAL.

      The pessimistic lock scope has no effect if the lock mode is null or NONE.

      Returns:
      the current pessimistic lock scope
      Throws:
      IllegalStateException - if the query is not a Jakarta Persistence query language SELECT query or a CriteriaQuery
      Since:
      4.0
    • setCacheRetrieveMode

      @Nonnull TypedQuery<X> setCacheRetrieveMode(@Nonnull CacheRetrieveMode cacheRetrieveMode)
      Set the cache retrieval mode in effect during query execution. This cache retrieval mode overrides the cache retrieve mode of the entity manager.
      Specified by:
      setCacheRetrieveMode in interface Query
      Parameters:
      cacheRetrieveMode - The new cache retrieval mode
      Returns:
      the same query instance
      Since:
      3.2
    • setCacheStoreMode

      @Nonnull TypedQuery<X> setCacheStoreMode(@Nonnull CacheStoreMode cacheStoreMode)
      Set the cache storage mode in effect during query execution. This cache storage mode overrides the cache storage mode of the entity manager.
      Specified by:
      setCacheStoreMode in interface Query
      Parameters:
      cacheStoreMode - The new cache storage mode
      Returns:
      the same query instance
      Since:
      3.2
    • getCacheRetrieveMode

      @Nonnull CacheRetrieveMode getCacheRetrieveMode()
      The cache retrieval mode in effect during query execution.
      Specified by:
      getCacheRetrieveMode in interface Query
      Returns:
      The current cache retrieval mode set by calling setCacheRetrieveMode(CacheRetrieveMode) or the cache retrieval mode of the persistence context if no cache retrieval mode has been explicitly specified for this query.
      Since:
      3.2
    • getCacheStoreMode

      @Nonnull CacheStoreMode getCacheStoreMode()
      The cache storage mode in effect during query execution.
      Specified by:
      getCacheStoreMode in interface Query
      Returns:
      The current cache storage mode set by calling setCacheStoreMode(CacheStoreMode) or the cache storage mode of the persistence context if no cache storage mode has been explicitly specified for this query.
      Since:
      3.2
    • setTimeout

      @Nonnull TypedQuery<X> setTimeout(@Nullable Integer timeout)
      Set the query timeout, in milliseconds. This is a hint, and is an alternative to setting the hint jakarta.persistence.query.timeout.
      Specified by:
      setTimeout in interface Query
      Parameters:
      timeout - the timeout, in milliseconds, or null to indicate no timeout
      Returns:
      the same query instance
      Since:
      3.2
    • setTimeout

      @Nonnull TypedQuery<X> setTimeout(@Nullable Timeout timeout)
      Set the query timeout. This is a hint.
      Specified by:
      setTimeout in interface Query
      Parameters:
      timeout - the timeout, or null to indicate no timeout
      Returns:
      the same query instance
      Since:
      4.0
    • executeUpdate

      @Deprecated(since="4.0", forRemoval=true) int executeUpdate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This operation should never be called on a TypedQuery. Any DELETE or UPDATE query should be represented by an untyped instance of Query or, preferably, by an instance of Statement.
      Description copied from interface: Query
      Execute an UPDATE or DELETE statement or a native SQL statement that returns a row count.

      After execution of a bulk update or delete operation, the persistence provider is not required to resynchronize state held in memory with the effects of the operation on data held in the database. However, when this method is called within a transaction, the persistence context is joined to the transaction, and FlushModeType.AUTO is in effect, the persistence provider must ensure that every modification to the state of every entity associated with the persistence context which could possibly alter the effects of the bulk update or delete operation is visible to the processing of the operation.

      Specified by:
      executeUpdate in interface Query
      Returns:
      the number of entities updated or deleted, or the row count of the native SQL statement
    • addOption

      @Nonnull TypedQuery<X> addOption(@Nonnull TypedQuery.Option option)
      Specify an option influencing execution of this typed query, overwriting any existing option of the same type.
      Parameters:
      option - the option
      Returns:
      the same query instance
      Since:
      4.0
    • getOptions

      @Nonnull Set<TypedQuery.Option> getOptions()
      Get the options influencing execution of this typed query. The returned set includes options set via addOption(TypedQuery.Option) along with options specified via setTimeout(Integer), setQueryFlushMode(QueryFlushMode), setCacheRetrieveMode(CacheRetrieveMode), setCacheStoreMode(CacheStoreMode), setLockMode(LockModeType), and setLockScope(PessimisticLockScope). Mutation of the returned set does not affect the options of the query.
      Returns:
      the options for this query
      Since:
      4.0