Top Description Fields
org.hibernate.jpa

public Interface HibernateHints

Known Direct Subinterfaces
org.hibernate.jpa.AvailableHints

List of Hibernate-specific (extension) hints available to query, load, and lock scenarios.

Some hints are only effective in certain scenarios, which is noted on each constant's documentation.

API Note

The stringly-typed hints defined here correspond to typesafe operations of Hibernate's native APIs, and should not be used unless portability between JPA implementations is of very great importance.

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
public static final String
HINT_BATCH_FETCH_SIZE

Hint to set the batch size for batch fetching for a given EntityManager.

public static final String
HINT_CACHE_MODE

Hint for specifying the org.hibernate.CacheMode to use.

public static final String
HINT_CACHE_REGION

Hint for specifying the region of the query cache into which the results should be stored.

public static final String
HINT_CACHEABLE

Hint for specifying whether results from a query should be stored in the query cache.

public static final String
HINT_CALLABLE_FUNCTION

Whether to treat a org.hibernate.procedure.ProcedureCall or jakarta.persistence.StoredProcedureQuery as a call to a function rather than a call to a procedure.

public static final String
HINT_COMMENT

Hint for specifying a database comment to be appended to the SQL statement sent to the database.

public static final String
HINT_ENABLE_SUBSELECT_FETCH

Hint to enable subselect fetching for a given EntityManager.

public static final String
HINT_FETCH_PROFILE

Hint to enable a fetch profile for a given EntityManager.

public static final String
HINT_FETCH_SIZE

Hint for specifying a JDBC fetch size to be applied to the statement.

public static final String
public static final String
HINT_FOLLOW_ON_LOCKING

Hint to enable or disable the follow-on locking mechanism provided by org.hibernate.dialect.Dialect#useFollowOnLocking.

public static final String
HINT_JDBC_BATCH_SIZE

Hint to set the batch size for JDBC batching for a given EntityManager.

public static final String
HINT_NATIVE_LOCK_MODE

Hint for specifying the lock mode to apply to the results of a native query.

public static final String
HINT_NATIVE_SPACES

Hint for specifying the query spaces that affect the results of a native query.

public static final String
HINT_QUERY_PLAN_CACHEABLE

Hint to enable or disable the query plan caching.

public static final String
HINT_READ_ONLY

Hint for specifying that objects loaded into the persistence context as a result of a query should be associated with the persistence context in read-only mode.

public static final String
HINT_TENANT_ID

Hint for specifying the tenant id to use when creating an EntityManager.

public static final String
HINT_TIMEOUT

Hint for specifying a query timeout, in seconds.

Field Detail

HINT_BATCH_FETCH_SIZEback to summary
public static final String HINT_BATCH_FETCH_SIZE

Hint to set the batch size for batch fetching for a given EntityManager.

See Also
org.hibernate.cfg.AvailableSettings#DEFAULT_BATCH_FETCH_SIZE, jakarta.persistence.EntityManager#setProperty(String, Object)
HINT_CACHE_MODEback to summary
public static final String HINT_CACHE_MODE

Hint for specifying the org.hibernate.CacheMode to use.

Implementation Specification

No effect unless HINT_CACHEABLE is set to true

See Also
org.hibernate.query.SelectionQuery#setCacheMode
HINT_CACHE_REGIONback to summary
public static final String HINT_CACHE_REGION

Hint for specifying the region of the query cache into which the results should be stored.

Implementation Specification

No effect unless HINT_CACHEABLE is set to true

See Also
org.hibernate.query.SelectionQuery#setCacheRegion
HINT_CACHEABLEback to summary
public static final String HINT_CACHEABLE

Hint for specifying whether results from a query should be stored in the query cache.

See Also
org.hibernate.query.SelectionQuery#setCacheable
HINT_CALLABLE_FUNCTIONback to summary
public static final String HINT_CALLABLE_FUNCTION

Whether to treat a org.hibernate.procedure.ProcedureCall or jakarta.persistence.StoredProcedureQuery as a call to a function rather than a call to a procedure.

HINT_COMMENTback to summary
public static final String HINT_COMMENT

Hint for specifying a database comment to be appended to the SQL statement sent to the database.

Implementation Specification

Not valid for org.hibernate.procedure.ProcedureCall, nor for jakarta.persistence.StoredProcedureQuery.

See Also
org.hibernate.query.SelectionQuery#setComment
HINT_ENABLE_SUBSELECT_FETCHback to summary
public static final String HINT_ENABLE_SUBSELECT_FETCH

Hint to enable subselect fetching for a given EntityManager.

See Also
org.hibernate.cfg.AvailableSettings#USE_SUBSELECT_FETCH, jakarta.persistence.EntityManager#setProperty(String, Object)
HINT_FETCH_PROFILEback to summary
public static final String HINT_FETCH_PROFILE

Hint to enable a fetch profile for a given EntityManager.

See Also
org.hibernate.Session#enableFetchProfile(String), jakarta.persistence.EntityManager#setProperty(String, Object)
HINT_FETCH_SIZEback to summary
public static final String HINT_FETCH_SIZE

Hint for specifying a JDBC fetch size to be applied to the statement.

See Also
org.hibernate.query.SelectionQuery#setFetchSize, java.sql.Statement#setFetchSize
HINT_FLUSH_MODEback to summary
public static final String HINT_FLUSH_MODE

Hint for specifying the org.hibernate.FlushMode to apply to an jakarta.persistence.EntityManager or jakarta.persistence.Query.

See Also
org.hibernate.query.Query#setHibernateFlushMode, org.hibernate.Session#setHibernateFlushMode
HINT_FOLLOW_ON_LOCKINGback to summary
public static final String HINT_FOLLOW_ON_LOCKING

Hint to enable or disable the follow-on locking mechanism provided by org.hibernate.dialect.Dialect#useFollowOnLocking.

A value of true enables follow-on-locking, whereas a value of false disables it. If the value is null, the dialect itself will determine whether follow-on locking is used.

Since
5.2
See Also
org.hibernate.LockOptions#setFollowOnLocking(Boolean)
HINT_JDBC_BATCH_SIZEback to summary
public static final String HINT_JDBC_BATCH_SIZE

Hint to set the batch size for JDBC batching for a given EntityManager.

See Also
org.hibernate.cfg.AvailableSettings#STATEMENT_BATCH_SIZE, jakarta.persistence.EntityManager#setProperty(String, Object)
HINT_NATIVE_LOCK_MODEback to summary
public static final String HINT_NATIVE_LOCK_MODE

Hint for specifying the lock mode to apply to the results of a native query.

Accepts either a jakarta.persistence.LockModeType or a org.hibernate.LockMode.

API Note

While Hibernate supports applying a lock mode to a native query, the JPA specification requires that jakarta.persistence.Query#setLockMode throw an IllegalStateException in this scenario.

HINT_NATIVE_SPACESback to summary
public static final String HINT_NATIVE_SPACES

Hint for specifying the query spaces that affect the results of a native query.

Passed value can be any of:

Typically, these are the names of tables which are referenced by the query.

See Also
org.hibernate.query.SynchronizeableQuery#addSynchronizedQuerySpace, HINT_FLUSH_MODE, org.hibernate.annotations.NamedNativeQuery#querySpaces
HINT_QUERY_PLAN_CACHEABLEback to summary
public static final String HINT_QUERY_PLAN_CACHEABLE

Hint to enable or disable the query plan caching.

By default, query plan caching is enabled for HQL queries and immutable criteria queries i.e. created with org.hibernate.cfg.AvailableSettings#CRITERIA_COPY_TREE. Query plan caching can be disabled for any query by setting this property to false. Query plan caching can be enabled for mutable criteria queries by setting this property to true.

Setting this property to true for mutable criteria queries can lead to cache trashing, because the query plan is cached based on a copy of the criteria query. This is mostly useful when the same org.hibernate.query.Query should be executed multiple times, but with different parameter values to avoid re-translation of the criteria query.

Note that setting this property to true does not override the basic safety measures of Hibernate. Hibernate will never cache query plans that are not safe to cache, regardless of the value of this property.

Since
6.3
See Also
org.hibernate.query.SelectionQuery#setQueryPlanCacheable
HINT_READ_ONLYback to summary
public static final String HINT_READ_ONLY

Hint for specifying that objects loaded into the persistence context as a result of a query should be associated with the persistence context in read-only mode.

See Also
org.hibernate.query.SelectionQuery#setReadOnly, org.hibernate.Session#setDefaultReadOnly
HINT_TENANT_IDback to summary
public static final String HINT_TENANT_ID

Hint for specifying the tenant id to use when creating an EntityManager.

See Also
org.hibernate.SessionBuilder#tenantIdentifier, jakarta.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
HINT_TIMEOUTback to summary
public static final String HINT_TIMEOUT

Hint for specifying a query timeout, in seconds.

See Also
org.hibernate.query.CommonQueryContract#setTimeout, java.sql.Statement#setQueryTimeout, SpecHints#HINT_SPEC_QUERY_TIMEOUT