Interface HibernateHints
-
- All Known Subinterfaces:
AvailableHints
public interface HibernateHints
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.
-
-
Field Summary
Fields Modifier and Type Field Description static String
HINT_BATCH_FETCH_SIZE
Hint to set the batch size for batch fetching for a givenEntityManager
.static String
HINT_CACHE_MODE
Hint for specifying theCacheMode
to use.static String
HINT_CACHE_REGION
Hint for specifying the region of the query cache into which the results should be stored.static String
HINT_CACHEABLE
Hint for specifying whether results from a query should be stored in the query cache.static String
HINT_CALLABLE_FUNCTION
Whether to treat aProcedureCall
orStoredProcedureQuery
as a call to a function rather than a call to a procedure.static String
HINT_COMMENT
Hint for specifying a database comment to be appended to the SQL statement sent to the database.static String
HINT_ENABLE_SUBSELECT_FETCH
Hint to enable subselect fetching for a givenEntityManager
.static String
HINT_FETCH_PROFILE
Hint to enable a fetch profile for a givenEntityManager
.static String
HINT_FETCH_SIZE
Hint for specifying a JDBC fetch size to be applied to the statement.static String
HINT_FLUSH_MODE
static String
HINT_FOLLOW_ON_LOCKING
Hint to enable or disable the follow-on locking mechanism provided byDialect.useFollowOnLocking(java.lang.String, org.hibernate.query.spi.QueryOptions)
.static String
HINT_JDBC_BATCH_SIZE
Hint to set the batch size for JDBC batching for a givenEntityManager
.static String
HINT_NATIVE_LOCK_MODE
Hint for specifying the lock mode to apply to the results of a native query.static String
HINT_NATIVE_SPACES
Hint for specifying the query spaces that affect the results of a native query.static String
HINT_QUERY_DATABASE
Hint for specifying a query hint to be appended to the SQL statement sent to the database.static String
HINT_QUERY_PLAN_CACHEABLE
Hint to enable or disable the query plan caching.static 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.static String
HINT_TENANT_ID
Hint for specifying the tenant id to use when creating anEntityManager
.static String
HINT_TIMEOUT
Hint for specifying a query timeout, in seconds.
-
-
-
Field Detail
-
HINT_FLUSH_MODE
static final String HINT_FLUSH_MODE
-
HINT_TIMEOUT
static final String HINT_TIMEOUT
Hint for specifying a query timeout, in seconds.
-
HINT_READ_ONLY
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.
-
HINT_FETCH_SIZE
static final String HINT_FETCH_SIZE
Hint for specifying a JDBC fetch size to be applied to the statement.
-
HINT_CACHEABLE
static final String HINT_CACHEABLE
Hint for specifying whether results from a query should be stored in the query cache.
-
HINT_CACHE_REGION
static final String HINT_CACHE_REGION
Hint for specifying the region of the query cache into which the results should be stored.- See Also:
SelectionQuery.setCacheRegion(java.lang.String)
, Constant Field Values- Implementation Specification:
- No effect unless
HINT_CACHEABLE
is set totrue
-
HINT_CACHE_MODE
static final String HINT_CACHE_MODE
Hint for specifying theCacheMode
to use.- See Also:
SelectionQuery.setCacheMode(org.hibernate.CacheMode)
, Constant Field Values- Implementation Specification:
- No effect unless
HINT_CACHEABLE
is set totrue
-
HINT_COMMENT
static final String HINT_COMMENT
Hint for specifying a database comment to be appended to the SQL statement sent to the database.- See Also:
SelectionQuery.setComment(java.lang.String)
, Constant Field Values- Implementation Specification:
- Not valid for
ProcedureCall
, nor forStoredProcedureQuery
.
-
HINT_FOLLOW_ON_LOCKING
static final String HINT_FOLLOW_ON_LOCKING
Hint to enable or disable the follow-on locking mechanism provided byDialect.useFollowOnLocking(java.lang.String, org.hibernate.query.spi.QueryOptions)
.A value of
true
enables follow-on-locking, whereas a value offalse
disables it. If the value isnull
, the dialect itself will determine whether follow-on locking is used.- Since:
- 5.2
- See Also:
LockOptions.setFollowOnLocking(Boolean)
, Constant Field Values
-
HINT_NATIVE_LOCK_MODE
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
LockModeType
or aLockMode
.- See Also:
- Constant Field Values
- API Note:
- While Hibernate supports applying a lock mode to a
native query, the JPA specification requires that
Query.setLockMode(jakarta.persistence.LockModeType)
throw anIllegalStateException
in this scenario.
-
HINT_NATIVE_SPACES
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:
- a
List
of the spaces, - an array of the spaces, or
- a string with a whitespace-separated list of the spaces.
Typically, these are the names of tables which are referenced by the query.
- a
-
HINT_CALLABLE_FUNCTION
static final String HINT_CALLABLE_FUNCTION
Whether to treat aProcedureCall
orStoredProcedureQuery
as a call to a function rather than a call to a procedure.- See Also:
- Constant Field Values
-
HINT_TENANT_ID
static final String HINT_TENANT_ID
Hint for specifying the tenant id to use when creating anEntityManager
.
-
HINT_FETCH_PROFILE
static final String HINT_FETCH_PROFILE
Hint to enable a fetch profile for a givenEntityManager
.
-
HINT_ENABLE_SUBSELECT_FETCH
static final String HINT_ENABLE_SUBSELECT_FETCH
Hint to enable subselect fetching for a givenEntityManager
.
-
HINT_BATCH_FETCH_SIZE
static final String HINT_BATCH_FETCH_SIZE
Hint to set the batch size for batch fetching for a givenEntityManager
.
-
HINT_JDBC_BATCH_SIZE
static final String HINT_JDBC_BATCH_SIZE
Hint to set the batch size for JDBC batching for a givenEntityManager
.
-
HINT_QUERY_PLAN_CACHEABLE
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
QuerySettings.CRITERIA_COPY_TREE
. Query plan caching can be disabled for any query by setting this property tofalse
. Query plan caching can be enabled for mutable criteria queries by setting this property totrue
.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 sameQuery
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:
SelectionQuery.setQueryPlanCacheable(boolean)
, Constant Field Values
-
HINT_QUERY_DATABASE
static final String HINT_QUERY_DATABASE
Hint for specifying a query hint to be appended to the SQL statement sent to the database.- Since:
- 6.5
- See Also:
MutableQueryOptions.addDatabaseHint(String)
,Query.addQueryHint(java.lang.String)
, Constant Field Values
-
-