Top Description Fields Constructors Methods
org.hibernate.annotations

public Class QueryHints

extends Object
Class Inheritance
Imports
org.hibernate.engine.spi.QueryParameters, org.hibernate.graph.GraphSemantic

Consolidation of hints available to Hibernate JPA queries. Mainly used to define features available on Hibernate queries that have no corollary in JPA queries.

Field Summary

Modifier and TypeField and Description
public static final String
CACHE_MODE

The cache mode to use.

public static final String
CACHE_REGION

The cache region to use.

public static final String
CACHEABLE

Are the query results cacheable?

public static final String
CALLABLE

Is the query callable?

public static final String
COMMENT

Defines a comment to be applied to the SQL sent to the database.

public static final String
FETCH_SIZE

Defines the JDBC fetch size to use.

public static final String
FETCHGRAPH

Hint providing a "fetchgraph" EntityGraph.

public static final String
FLUSH_MODE

The flush mode to associate with the execution of the query.

public static final String
FOLLOW_ON_LOCKING

Hint to enable/disable the follow-on-locking mechanism provided by org.hibernate.dialect.Dialect#useFollowOnLocking(QueryParameters).

public static final String
LOADGRAPH

Hint providing a "loadgraph" EntityGraph.

public static final String
NATIVE_LOCKMODE

Available to apply lock mode to a native SQL query since JPA requires that javax.persistence.Query#setLockMode throw an IllegalStateException if called for a native query.

public static final String
NATIVE_SPACES

Hint for specifying query spaces to be applied to a native (SQL) query.

public static final String
PASS_DISTINCT_THROUGH

Hint to enable/disable the pass-distinct-through mechanism.

public static final String
READ_ONLY

Should entities returned from the query be set in read only mode?

public static final String
TIMEOUT_HIBERNATE

Apply a Hibernate query timeout, which is defined in seconds.

public static final String
TIMEOUT_JAKARTA_JPA

Apply a JPA query timeout, which is defined in milliseconds.

public static final String
TIMEOUT_JPA

Apply a JPA query timeout, which is defined in milliseconds.

Constructor Summary

AccessConstructor and Description
private
QueryHints()

Disallow instantiation.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHE_MODEback to summary
public static final String CACHE_MODE

The cache mode to use.

See Also
org.hibernate.Query#setCacheMode, org.hibernate.SQLQuery#setCacheMode
CACHE_REGIONback to summary
public static final String CACHE_REGION

The cache region to use.

See Also
org.hibernate.Query#setCacheRegion, org.hibernate.SQLQuery#setCacheRegion
CACHEABLEback to summary
public static final String CACHEABLE

Are the query results cacheable?

See Also
org.hibernate.Query#setCacheable, org.hibernate.SQLQuery#setCacheable
CALLABLEback to summary
public static final String CALLABLE

Is the query callable? Note: only valid for named native sql queries.

COMMENTback to summary
public static final String COMMENT

Defines a comment to be applied to the SQL sent to the database.

See Also
org.hibernate.Query#setComment, org.hibernate.SQLQuery#setComment
FETCH_SIZEback to summary
public static final String FETCH_SIZE

Defines the JDBC fetch size to use.

See Also
org.hibernate.Query#setFetchSize, org.hibernate.SQLQuery#setFetchSize
FETCHGRAPHback to summary
public static final String FETCHGRAPH

Deprecated

(since 5.4) Use GraphSemantic#FETCH's GraphSemantic#getJpaHintName() instead

Hint providing a "fetchgraph" EntityGraph. Attributes explicitly specified as AttributeNodes are treated as FetchType.EAGER (via join fetch or subsequent select).

Note

Currently, attributes that are not specified are treated as FetchType.LAZY or FetchType.EAGER depending on the attribute's definition in metadata, rather than forcing FetchType.LAZY.

Annotations
@Deprecated
FLUSH_MODEback to summary
public static final String FLUSH_MODE

The flush mode to associate with the execution of the query.

See Also
org.hibernate.Query#setFlushMode, org.hibernate.SQLQuery#setFlushMode, org.hibernate.Session#setFlushMode
FOLLOW_ON_LOCKINGback to summary
public static final String FOLLOW_ON_LOCKING

Hint to enable/disable the follow-on-locking mechanism provided by org.hibernate.dialect.Dialect#useFollowOnLocking(QueryParameters). A value of true enables follow-on-locking, whereas a value of false disables it. If the value is null, the Dialect strategy is going to be used instead.

Since
5.2
LOADGRAPHback to summary
public static final String LOADGRAPH

Deprecated

(since 5.4) Use GraphSemantic#LOAD's GraphSemantic#getJpaHintName() instead

Hint providing a "loadgraph" EntityGraph. Attributes explicitly specified as AttributeNodes are treated as FetchType.EAGER (via join fetch or subsequent select). Attributes that are not specified are treated as FetchType.LAZY or FetchType.EAGER depending on the attribute's definition in metadata

Annotations
@Deprecated
NATIVE_LOCKMODEback to summary
public static final String NATIVE_LOCKMODE

Available to apply lock mode to a native SQL query since JPA requires that javax.persistence.Query#setLockMode throw an IllegalStateException if called for a native query.

Accepts a javax.persistence.LockModeType or a org.hibernate.LockMode

NATIVE_SPACESback to summary
public static final String NATIVE_SPACES

Hint for specifying query spaces to be applied to a native (SQL) query. Passed value can be any of:

  • List of the spaces
  • array of the spaces
  • String "whitespace"-separated list of the spaces
See Also
org.hibernate.SynchronizeableQuery
PASS_DISTINCT_THROUGHback to summary
public static final String PASS_DISTINCT_THROUGH

Hint to enable/disable the pass-distinct-through mechanism. A value of true enables pass-distinct-through, whereas a value of false disables it. When the pass-distinct-through is disabled, the HQL and JPQL distinct clause is no longer passed to the SQL statement.

Since
5.2
READ_ONLYback to summary
public static final String READ_ONLY

Should entities returned from the query be set in read only mode?

See Also
org.hibernate.Query#setReadOnly, org.hibernate.SQLQuery#setReadOnly, org.hibernate.Session#setReadOnly
TIMEOUT_HIBERNATEback to summary
public static final String TIMEOUT_HIBERNATE

Apply a Hibernate query timeout, which is defined in seconds.

See Also
org.hibernate.Query#setTimeout, org.hibernate.SQLQuery#setTimeout
TIMEOUT_JAKARTA_JPAback to summary
public static final String TIMEOUT_JAKARTA_JPA

Apply a JPA query timeout, which is defined in milliseconds.

TIMEOUT_JPAback to summary
public static final String TIMEOUT_JPA

Apply a JPA query timeout, which is defined in milliseconds.

Constructor Detail

QueryHintsback to summary
private QueryHints()

Disallow instantiation.