Interface SelectionQuery<R>
-
- All Superinterfaces:
CommonQueryContract
- All Known Subinterfaces:
NativeQuery<T>
,NativeQueryImplementor<R>
,ProcedureCallImplementor<R>
,Query<R>
,QueryImplementor<R>
,SqmQueryImplementor<R>
,SqmSelectionQuery<R>
,SqmSelectionQueryImplementor<R>
- All Known Implementing Classes:
AbstractQuery
,AbstractSelectionQuery
,DelegatingSqmSelectionQueryImplementor
,NativeQueryImpl
,ProcedureCallImpl
,QuerySqmImpl
,SqmSelectionQueryImpl
@Incubating public interface SelectionQuery<R> extends CommonQueryContract
Within the context of an active session, an instance of this type represents an executable selection query, that is, aselect
. It is a slimmed-down version ofQuery
, providing only methods relevant to selection queries.A
SelectionQuery
may be obtained from theSession
by calling:QueryProducer.createSelectionQuery(String, Class)
, passing the HQL as a string,QueryProducer.createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery)
, passing a criteria query object, orQueryProducer.createNamedSelectionQuery(String, Class)
passing the name of a query defined usingNamedQuery
orNamedNativeQuery
.
A
SelectionQuery
controls how a query is executed, and allows arguments to be bound to its parameters.- Selection queries are usually executed using
getResultList()
orgetSingleResult()
. - The methods
setMaxResults(int)
andsetFirstResult(int)
control limits and pagination. - The various overloads of
setParameter(String, Object)
andsetParameter(int, Object)
allow arguments to be bound to named and ordinal parameters defined by the query.
A query may have explicit fetch joins, specified using the syntax
join fetch
in HQL, or viaFetchParent.fetch(jakarta.persistence.metamodel.SingularAttribute<? super X, Y>)
in the criteria API. Additional fetch joins may be added by:- setting an
EntityGraph
by callingsetEntityGraph(EntityGraph, GraphSemantic)
, or - enabling a fetch profile, using
Session.enableFetchProfile(String)
.
The special built-in fetch profile named "org.hibernate.defaultProfile" adds a fetch join for every
eager
@ManyToOne
or@OneToOne
association belonging to an entity returned by the query.Finally, two alternative approaches to pagination are available:
-
The operations and
setOrder(List)
andsetPage(Page)
, together withOrder
andPage
, provide a streamlined API for offset-based pagination, at a slightly higher semantic level than the ancient but dependablesetFirstResult(int)
andsetMaxResults(int)
. -
On the other hand,
KeyedPage
andKeyedResultList
, along withgetKeyedResultList(KeyedPage)
, provide for key-based pagination, which can help eliminate missed or duplicate results when data is modified between page requests.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description SelectionQuery<R>
disableFetchProfile(String profileName)
Disable thefetch profile
with the given name in this session.SelectionQuery<R>
enableFetchProfile(String profileName)
Enable thefetch profile
for this query.CacheMode
getCacheMode()
Obtain theCacheMode
in effect for this query.String
getCacheRegion()
Obtain the name of the second level query cache region in which query results will be stored (if they are cached, see the discussion onisCacheable()
for more information).CacheRetrieveMode
getCacheRetrieveMode()
CacheStoreMode
getCacheStoreMode()
Integer
getFetchSize()
Obtain the JDBC fetch size hint in effect for this query.int
getFirstResult()
The first row position to return from the query results.LockMode
getHibernateLockMode()
Get the rootLockMode
for the queryKeyedResultList<R>
getKeyedResultList(KeyedPage<R> page)
Execute the query and return the results for the given page, using key-based pagination.LockModeType
getLockMode()
Get the rootLockModeType
for the queryLockOptions
getLockOptions()
TheLockOptions
currently in effect for the queryint
getMaxResults()
The max number of rows requested for the query resultslong
getResultCount()
Determine the size of the query result list that would be returned by callinggetResultList()
with no offset or limit applied to the query.default List<R>
getResultList()
Execute the query and return the query results as aList
.default Stream<R>
getResultStream()
Execute the query and return the query results as aStream
.R
getSingleResult()
Execute the query and return the single result of the query, throwing an exception if the query returns no results.R
getSingleResultOrNull()
Execute the query and return the single result of the query, ornull
if the query returns no results.boolean
isCacheable()
Should the results of the query be stored in the second level cache?boolean
isQueryPlanCacheable()
Should the query plan of the query be stored in the query plan cache?boolean
isReadOnly()
Should entities and proxies loaded by this Query be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context i s returned instead.List<R>
list()
Execute the query and return the query results as aList
.ScrollableResults<R>
scroll()
Returns scrollable access to the query results.ScrollableResults<R>
scroll(ScrollMode scrollMode)
Returns scrollable access to the query results.@Remove SelectionQuery<R>
setAliasSpecificLockMode(String alias, LockMode lockMode)
Deprecated.SelectionQuery<R>
setCacheable(boolean cacheable)
Enable/disable second level query (result) caching for this query.SelectionQuery<R>
setCacheMode(CacheMode cacheMode)
Set the currentCacheMode
in effect for this query.SelectionQuery<R>
setCacheRegion(String cacheRegion)
Set the name of the cache region where query results should be cached (assumingisCacheable()
).SelectionQuery<R>
setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
SelectionQuery<R>
setCacheStoreMode(CacheStoreMode cacheStoreMode)
SelectionQuery<R>
setComment(String comment)
Set a comment for this query.SelectionQuery<R>
setEntityGraph(EntityGraph<R> graph, GraphSemantic semantic)
Apply anEntityGraph
to the query.SelectionQuery<R>
setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.SelectionQuery<R>
setFirstResult(int startPosition)
Set the first row position to return from the query results.SelectionQuery<R>
setFlushMode(FlushModeType flushMode)
Set theFlushMode
in to use for this query.SelectionQuery<R>
setFollowOnLocking(boolean enable)
Specifies whether follow-on locking should be appliedSelectionQuery<R>
setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
in effect for this query.SelectionQuery<R>
setHibernateLockMode(LockMode lockMode)
Specify the rootLockMode
for the querySelectionQuery<R>
setHint(String hintName, Object value)
Set a hint.SelectionQuery<R>
setLockMode(LockModeType lockMode)
Specify the rootLockModeType
for the querySelectionQuery<R>
setLockMode(String alias, LockMode lockMode)
Specify aLockMode
to apply to a specific alias defined in the querySelectionQuery<R>
setMaxResults(int maxResult)
Set the max number of rows requested for the query results.SelectionQuery<R>
setOrder(List<Order<? super R>> orderList)
If the result type of this query is an entity class, add one or more rules for ordering the query results.SelectionQuery<R>
setOrder(Order<? super R> order)
If the result type of this query is an entity class, add a rule for ordering the query results.SelectionQuery<R>
setPage(Page page)
Set the page of results to return.SelectionQuery<R>
setParameter(int position, Object value)
Bind the given argument to an ordinal query parameter.SelectionQuery<R>
setParameter(int position, Instant value, TemporalType temporalType)
Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
.SelectionQuery<R>
setParameter(int position, Calendar value, TemporalType temporalType)
SelectionQuery<R>
setParameter(int position, Date value, TemporalType temporalType)
<P> SelectionQuery<R>
setParameter(int position, P value, Class<P> type)
Bind the given argument to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.<P> SelectionQuery<R>
setParameter(int position, P value, BindableType<P> type)
Bind the given argument to an ordinal query parameter using the givenBindableType
.SelectionQuery<R>
setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
SelectionQuery<R>
setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
<T> SelectionQuery<R>
setParameter(Parameter<T> param, T value)
SelectionQuery<R>
setParameter(String name, Object value)
Bind the given argument to a named query parameter.SelectionQuery<R>
setParameter(String name, Instant value, TemporalType temporalType)
Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
.SelectionQuery<R>
setParameter(String name, Calendar value, TemporalType temporalType)
SelectionQuery<R>
setParameter(String name, Date value, TemporalType temporalType)
<P> SelectionQuery<R>
setParameter(String name, P value, Class<P> type)
Bind the given argument to a named query parameter using the givenClass
reference to attempt to infer theBindableType
.<P> SelectionQuery<R>
setParameter(String name, P value, BindableType<P> type)
Bind the given argument to a named query parameter using the givenBindableType
.<P> SelectionQuery<R>
setParameter(QueryParameter<P> parameter, P value, Class<P> type)
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenClass
reference to attempt to infer theBindableType
to use.<P> SelectionQuery<R>
setParameter(QueryParameter<P> parameter, P val, BindableType<P> type)
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.<T> SelectionQuery<R>
setParameter(QueryParameter<T> parameter, T value)
Bind an argument to the query parameter represented by the givenQueryParameter
.SelectionQuery<R>
setParameterList(int position, Object[] values)
Bind multiple arguments to an ordinal query parameter.SelectionQuery<R>
setParameterList(int position, Collection values)
Bind multiple arguments to an ordinal query parameter.<P> SelectionQuery<R>
setParameterList(int position, Collection<? extends P> values, Class<P> javaType)
Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.<P> SelectionQuery<R>
setParameterList(int position, Collection<? extends P> values, BindableType<P> type)
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.<P> SelectionQuery<R>
setParameterList(int position, P[] values, Class<P> javaType)
Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.<P> SelectionQuery<R>
setParameterList(int position, P[] values, BindableType<P> type)
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.SelectionQuery<R>
setParameterList(String name, Object[] values)
Bind multiple arguments to a named query parameter.SelectionQuery<R>
setParameterList(String name, Collection values)
Bind multiple arguments to a named query parameter.<P> SelectionQuery<R>
setParameterList(String name, Collection<? extends P> values, Class<P> javaType)
Bind multiple arguments to a named query parameter using the givenClass
reference to attempt to infer theBindableType
If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameterList(String, Collection)
.<P> SelectionQuery<R>
setParameterList(String name, Collection<? extends P> values, BindableType<P> type)
Bind multiple arguments to a named query parameter using the givenBindableType
.<P> SelectionQuery<R>
setParameterList(String name, P[] values, Class<P> javaType)
Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theBindableType
to use.<P> SelectionQuery<R>
setParameterList(String name, P[] values, BindableType<P> type)
Bind multiple arguments to a named query parameter using the givenBindableType
.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, Collection<? extends P> values)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
using the givenClass
reference to attempt to infer theBindableType
to use.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, P[] values)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
using the givenClass
reference to attempt to infer theBindableType
to use.<P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the given theBindableType
.SelectionQuery<R>
setProperties(Object bean)
Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using heuristics.SelectionQuery<R>
setProperties(Map bean)
Bind the values of the givenMap
to named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.SelectionQuery<R>
setQueryPlanCacheable(boolean queryPlanCacheable)
Enable/disable query plan caching for this query.SelectionQuery<R>
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies loaded by thisQuery
.SelectionQuery<R>
setTimeout(int timeout)
Set the query timeout in seconds.default Stream<R>
stream()
Execute the query and return the query results as aStream
.R
uniqueResult()
Execute the query and return the single result of the query, ornull
if the query returns no results.Optional<R>
uniqueResultOptional()
Execute the query and return the single result of the query, as anOptional
.-
Methods inherited from interface org.hibernate.query.CommonQueryContract
getComment, getFlushMode, getHibernateFlushMode, getTimeout
-
-
-
-
Method Detail
-
list
List<R> list()
Execute the query and return the query results as aList
. If the query contains multiple items in the selection list, then by default each result in the list is packaged in an array of typeObject[]
.- Returns:
- the result list
-
getResultList
default List<R> getResultList()
Execute the query and return the query results as aList
. If the query contains multiple items in the selection list, then by default each result in the list is packaged in an array of typeObject[]
.- Returns:
- the results as a list
-
scroll
ScrollableResults<R> scroll()
Returns scrollable access to the query results.This form calls
scroll(ScrollMode)
usingDialect.defaultScrollMode()
- API Note:
- The exact behavior of this method depends somewhat
on the JDBC driver's
ResultSet
scrolling support
-
scroll
ScrollableResults<R> scroll(ScrollMode scrollMode)
Returns scrollable access to the query results. The capabilities of the returned ScrollableResults depend on the specified ScrollMode.- API Note:
- The exact behavior of this method depends somewhat
on the JDBC driver's
ResultSet
scrolling support
-
getResultStream
default Stream<R> getResultStream()
Execute the query and return the query results as aStream
. If the query contains multiple items in the selection list, then by default each result in the stream is packaged in an array of typeObject[]
.The client should call
BaseStream.close()
after processing the stream so that resources are freed as soon as possible.
-
stream
default Stream<R> stream()
Execute the query and return the query results as aStream
. If the query contains multiple items in the selection list, then by default each result in the stream is packaged in an array of typeObject[]
.The client should call
BaseStream.close()
after processing the stream so that resources are freed as soon as possible.- Returns:
- The results as a
Stream
- Since:
- 5.2
-
uniqueResult
R uniqueResult()
Execute the query and return the single result of the query, ornull
if the query returns no results.- Returns:
- the single result or
null
- Throws:
NonUniqueResultException
- if there is more than one matching result
-
getSingleResult
R getSingleResult()
Execute the query and return the single result of the query, throwing an exception if the query returns no results.- Returns:
- the single result, only if there is exactly one
- Throws:
NonUniqueResultException
- if there is more than one matching resultNoResultException
- if there is no result to return
-
getSingleResultOrNull
R getSingleResultOrNull()
Execute the query and return the single result of the query, ornull
if the query returns no results.- Returns:
- the single result or
null
if there is no result to return - Throws:
NonUniqueResultException
- if there is more than one matching result- Since:
- 6.0
-
uniqueResultOptional
Optional<R> uniqueResultOptional()
Execute the query and return the single result of the query, as anOptional
.- Returns:
- the single result as an
Optional
- Throws:
NonUniqueResultException
- if there is more than one matching result
-
getResultCount
@Incubating long getResultCount()
Determine the size of the query result list that would be returned by callinggetResultList()
with no offset or limit applied to the query.- Returns:
- the size of the list that would be returned
- Since:
- 6.5
-
getKeyedResultList
@Incubating KeyedResultList<R> getKeyedResultList(KeyedPage<R> page)
Execute the query and return the results for the given page, using key-based pagination.- Parameters:
page
- the key-based specification of the page as an instance ofKeyedPage
- Returns:
- the query results and the key of the next page
as an instance of
KeyedResultList
- Since:
- 6.5
- See Also:
KeyedPage
,KeyedResultList
-
setHint
SelectionQuery<R> setHint(String hintName, Object value)
Description copied from interface:CommonQueryContract
Set a hint. The hints understood by Hibernate are enumerated byAvailableHints
.- Specified by:
setHint
in interfaceCommonQueryContract
- See Also:
HibernateHints
,SpecHints
-
setEntityGraph
SelectionQuery<R> setEntityGraph(EntityGraph<R> graph, GraphSemantic semantic)
Apply anEntityGraph
to the query.This is an alternative way to specify the associations which should be fetched as part of the initial query.
- Since:
- 6.3
-
enableFetchProfile
SelectionQuery<R> enableFetchProfile(String profileName)
Enable thefetch profile
for this query. If the requested fetch profile is already enabled, the call has no effect.This is an alternative way to specify the associations which should be fetched as part of the initial query.
- Parameters:
profileName
- the name of the fetch profile to be enabled- Throws:
UnknownProfileException
- Indicates that the given name does not match any known fetch profile names- See Also:
FetchProfile
-
disableFetchProfile
SelectionQuery<R> disableFetchProfile(String profileName)
Disable thefetch profile
with the given name in this session. If the requested fetch profile is not currently enabled, the call has no effect.- Parameters:
profileName
- the name of the fetch profile to be disabled- Throws:
UnknownProfileException
- Indicates that the given name does not match any known fetch profile names- See Also:
FetchProfile
-
setFlushMode
SelectionQuery<R> setFlushMode(FlushModeType flushMode)
Description copied from interface:CommonQueryContract
Set theFlushMode
in to use for this query.- Specified by:
setFlushMode
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.getHibernateFlushMode()
,Session.getHibernateFlushMode()
-
setHibernateFlushMode
SelectionQuery<R> setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:CommonQueryContract
Set the currentFlushMode
in effect for this query.- Specified by:
setHibernateFlushMode
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.getHibernateFlushMode()
,Session.getHibernateFlushMode()
-
setTimeout
SelectionQuery<R> setTimeout(int timeout)
Description copied from interface:CommonQueryContract
Set the query timeout in seconds.Any value set here is eventually passed directly along to the JDBC statement, which expressly disallows negative values. So negative values should be avoided as a general rule.
A value of zero indicates no timeout.
- Specified by:
setTimeout
in interfaceCommonQueryContract
- Parameters:
timeout
- the timeout in seconds- Returns:
this
, for method chaining- See Also:
CommonQueryContract.getTimeout()
-
setComment
SelectionQuery<R> setComment(String comment)
Description copied from interface:CommonQueryContract
Set a comment for this query.- Specified by:
setComment
in interfaceCommonQueryContract
- See Also:
Query.setComment(String)
-
getFetchSize
Integer getFetchSize()
Obtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC query viaStatement.setFetchSize(int)
. As defined by JDBC, this value is a hint to the driver to indicate how many rows to fetch from the database when more rows are needed.- Returns:
- The timeout in seconds
- See Also:
Statement.getFetchSize()
,Statement.setFetchSize(int)
- Implementation Note:
- JDBC expressly defines this value as a hint. Depending on the driver, it may or may not have any
effect on the actual query execution and
ResultSet
processing .
-
setFetchSize
SelectionQuery<R> setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.- Parameters:
fetchSize
- the fetch size hint- Returns:
this
, for method chaining- See Also:
getFetchSize()
-
isReadOnly
boolean isReadOnly()
Should entities and proxies loaded by this Query be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context i s returned instead.- Returns:
true
if the entities and proxies loaded by the query will be put in read-only mode;false
otherwise (they will be modifiable)- See Also:
setReadOnly(boolean)
,The read-only/modifiable setting has no impact on entities/proxies returned by the query that existed in the session beforeQuery the query was executed.
-
setReadOnly
SelectionQuery<R> setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies loaded by thisQuery
. This setting overrides the default setting for the persistence context,Session.isDefaultReadOnly()
.To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session, use
Session.setDefaultReadOnly(boolean)
.Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted.
When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting.
The read-only/modifiable setting has no impact on entities/proxies returned by the query that existed in the session beforeQuery the query was executed.
- Parameters:
readOnly
-true
indicates that entities and proxies loaded by the query are to be put in read-only mode;false
indicates that entities and proxies loaded by the query will be put in modifiable mode- Returns:
this
, for method chaining
-
getMaxResults
int getMaxResults()
The max number of rows requested for the query results
-
setMaxResults
SelectionQuery<R> setMaxResults(int maxResult)
Set the max number of rows requested for the query results. Applied to the SQL query
-
getFirstResult
int getFirstResult()
The first row position to return from the query results. Applied to the SQL query.
-
setFirstResult
SelectionQuery<R> setFirstResult(int startPosition)
Set the first row position to return from the query results. Applied to the SQL query.
-
setPage
@Incubating SelectionQuery<R> setPage(Page page)
Set the page of results to return.- Since:
- 6.3
- See Also:
Page
-
getCacheMode
CacheMode getCacheMode()
Obtain theCacheMode
in effect for this query. By default, the query inherits theCacheMode
of the session from which it originates.The
CacheMode
here describes reading-from/writing-to the entity/collection caches as we process query results. For caching of the actual query results, seeisCacheable()
andgetCacheRegion()
In order for this setting to have any affect, second-level caching would have to be enabled and the entities/collections in question configured for caching.
- See Also:
Session.getCacheMode()
-
getCacheStoreMode
CacheStoreMode getCacheStoreMode()
- Since:
- 6.2
- See Also:
getCacheMode()
-
getCacheRetrieveMode
CacheRetrieveMode getCacheRetrieveMode()
- Since:
- 6.2
- See Also:
getCacheMode()
-
setCacheMode
SelectionQuery<R> setCacheMode(CacheMode cacheMode)
Set the currentCacheMode
in effect for this query.- See Also:
getCacheMode()
,Session.setCacheMode(CacheMode)
- Implementation Note:
- Setting it to
null
ultimately indicates to use theCacheMode
of the session.
-
setCacheStoreMode
SelectionQuery<R> setCacheStoreMode(CacheStoreMode cacheStoreMode)
- Since:
- 6.2
- See Also:
setCacheMode(CacheMode)
-
setCacheRetrieveMode
SelectionQuery<R> setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
- Since:
- 6.2
- See Also:
setCacheMode(CacheMode)
-
isCacheable
boolean isCacheable()
Should the results of the query be stored in the second level cache?This is different to second level caching of any returned entities and collections, which is controlled by
getCacheMode()
.The query being "eligible" for caching does not necessarily mean its results will be cached. Second-level query caching still has to be enabled on the
SessionFactory
for this to happen. Usually that is controlled by the configuration setting "hibernate.cache.use_query_cache".
-
setCacheable
SelectionQuery<R> setCacheable(boolean cacheable)
Enable/disable second level query (result) caching for this query.- See Also:
isCacheable()
-
isQueryPlanCacheable
boolean isQueryPlanCacheable()
Should the query plan of the query be stored in the query plan cache?
-
setQueryPlanCacheable
SelectionQuery<R> setQueryPlanCacheable(boolean queryPlanCacheable)
Enable/disable query plan caching for this query.- See Also:
isQueryPlanCacheable()
-
getCacheRegion
String getCacheRegion()
Obtain the name of the second level query cache region in which query results will be stored (if they are cached, see the discussion onisCacheable()
for more information).null
indicates that the default region should be used.
-
setCacheRegion
SelectionQuery<R> setCacheRegion(String cacheRegion)
Set the name of the cache region where query results should be cached (assumingisCacheable()
).null
indicates to use the default region.- See Also:
getCacheRegion()
-
getLockOptions
LockOptions getLockOptions()
TheLockOptions
currently in effect for the query
-
getLockMode
LockModeType getLockMode()
Get the rootLockModeType
for the query- See Also:
getHibernateLockMode()
-
setLockMode
SelectionQuery<R> setLockMode(LockModeType lockMode)
Specify the rootLockModeType
for the query
-
getHibernateLockMode
LockMode getHibernateLockMode()
Get the rootLockMode
for the query- See Also:
getLockMode()
-
setHibernateLockMode
SelectionQuery<R> setHibernateLockMode(LockMode lockMode)
Specify the rootLockMode
for the query- See Also:
setLockMode(LockModeType)
-
setLockMode
SelectionQuery<R> setLockMode(String alias, LockMode lockMode)
Specify aLockMode
to apply to a specific alias defined in the query
-
setOrder
@Incubating SelectionQuery<R> setOrder(List<Order<? super R>> orderList)
If the result type of this query is an entity class, add one or more rules for ordering the query results.
-
setOrder
@Incubating SelectionQuery<R> setOrder(Order<? super R> order)
If the result type of this query is an entity class, add a rule for ordering the query results.
-
setAliasSpecificLockMode
@Deprecated(since="6.2") @Remove @Remove SelectionQuery<R> setAliasSpecificLockMode(String alias, LockMode lockMode)
Deprecated.Specify aLockMode
to apply to a specific alias defined in the query
-
setFollowOnLocking
SelectionQuery<R> setFollowOnLocking(boolean enable)
Specifies whether follow-on locking should be applied
-
setParameter
SelectionQuery<R> setParameter(String name, Object value)
Description copied from interface:CommonQueryContract
Bind the given argument to a named query parameter.If the type of the parameter cannot be inferred from the context in which it occurs, use one of the forms which accepts a "type".
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.setParameter(String, Object, Class)
,CommonQueryContract.setParameter(String, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(String name, P value, Class<P> type)
Description copied from interface:CommonQueryContract
Bind the given argument to a named query parameter using the givenClass
reference to attempt to infer theBindableType
. If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameter(String, Object)
.- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.setParameter(String, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(String name, P value, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind the given argument to a named query parameter using the givenBindableType
.- Specified by:
setParameter
in interfaceCommonQueryContract
-
setParameter
SelectionQuery<R> setParameter(String name, Instant value, TemporalType temporalType)
Description copied from interface:CommonQueryContract
Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
.- Specified by:
setParameter
in interfaceCommonQueryContract
-
setParameter
SelectionQuery<R> setParameter(String name, Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(String, Calendar, TemporalType)
-
setParameter
SelectionQuery<R> setParameter(String name, Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(String, Date, TemporalType)
-
setParameter
SelectionQuery<R> setParameter(int position, Object value)
Description copied from interface:CommonQueryContract
Bind the given argument to an ordinal query parameter.If the type of the parameter cannot be inferred from the context in which it occurs, use one of the forms which accepts a "type".
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.setParameter(int, Object, Class)
,CommonQueryContract.setParameter(int, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(int position, P value, Class<P> type)
Description copied from interface:CommonQueryContract
Bind the given argument to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
. If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameter(int, Object)
.- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
CommonQueryContract.setParameter(int, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(int position, P value, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind the given argument to an ordinal query parameter using the givenBindableType
.- Specified by:
setParameter
in interfaceCommonQueryContract
-
setParameter
SelectionQuery<R> setParameter(int position, Instant value, TemporalType temporalType)
Description copied from interface:CommonQueryContract
Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
.- Specified by:
setParameter
in interfaceCommonQueryContract
-
setParameter
SelectionQuery<R> setParameter(int position, Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(int, Date, TemporalType)
-
setParameter
SelectionQuery<R> setParameter(int position, Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(int, Calendar, TemporalType)
-
setParameter
<T> SelectionQuery<R> setParameter(QueryParameter<T> parameter, T value)
Description copied from interface:CommonQueryContract
Bind an argument to the query parameter represented by the givenQueryParameter
.If the type of the parameter cannot be inferred from the context in which it occurs, use one of the forms which accepts a "type".
- Specified by:
setParameter
in interfaceCommonQueryContract
- Parameters:
parameter
- the query parameter mementovalue
- the argument, which might be null- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameter(QueryParameter, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(QueryParameter<P> parameter, P value, Class<P> type)
Description copied from interface:CommonQueryContract
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenClass
reference to attempt to infer theBindableType
to use. If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameter(QueryParameter, Object)
.- Specified by:
setParameter
in interfaceCommonQueryContract
- Parameters:
parameter
- the query parameter mementovalue
- the argument, which might be nulltype
- aBindableType
representing the type of the parameter- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameter(QueryParameter, Object, BindableType)
-
setParameter
<P> SelectionQuery<R> setParameter(QueryParameter<P> parameter, P val, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.- Specified by:
setParameter
in interfaceCommonQueryContract
- Parameters:
parameter
- the query parameter mementoval
- the argument, which might be nulltype
- aBindableType
representing the type of the parameter- Returns:
this
, for method chaining
-
setParameter
<T> SelectionQuery<R> setParameter(Parameter<T> param, T value)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(Parameter, Object)
-
setParameter
SelectionQuery<R> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(Parameter, Calendar, TemporalType)
-
setParameter
SelectionQuery<R> setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceCommonQueryContract
- See Also:
Query.setParameter(Parameter, Date, TemporalType)
-
setParameterList
SelectionQuery<R> setParameterList(String name, Collection values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter.The "type mapping" for the binding is inferred from the type of the first collection element.
- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(java.lang.String, java.util.Collection, BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter using the givenClass
reference to attempt to infer theBindableType
If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameterList(String, Collection)
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(java.lang.String, java.util.Collection, BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter using the givenBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
SelectionQuery<R> setParameterList(String name, Object[] values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(String name, P[] values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theBindableType
to use. If unable to determine an appropriateBindableType
,CommonQueryContract.setParameterList(String, Collection)
is used- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(java.lang.String, Object[], BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(String name, P[] values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to a named query parameter using the givenBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
SelectionQuery<R> setParameterList(int position, Collection values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
. If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameterList(String, Collection)
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(int, Collection, BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(int position, Collection<? extends P> values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
SelectionQuery<R> setParameterList(int position, Object[] values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(int position, P[] values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
. If unable to infer an appropriateBindableType
, fall back toCommonQueryContract.setParameterList(String, Collection)
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(int, Object[], BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(int position, P[] values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.The type of the parameter is inferred from the context in which it occurs, and from the type of the first given argument.
- Specified by:
setParameterList
in interfaceCommonQueryContract
- Parameters:
parameter
- the parameter mementovalues
- a collection of arguments- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
using the givenClass
reference to attempt to infer theBindableType
to use. If unable to infer an appropriateBindableType
, fall back to usingCommonQueryContract.setParameterList(String, Collection)
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(QueryParameter, java.util.Collection, BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, P[] values)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.The type of the parameter is inferred between the context in which it occurs, the type associated with the
QueryParameter
and the type of the first given argument.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Parameters:
parameter
- the parameter mementovalues
- a collection of arguments- Returns:
this
, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
using the givenClass
reference to attempt to infer theBindableType
to use. If unable to infer an appropriateBindableType
, fall back to usingCommonQueryContract.setParameterList(String, Collection)
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining- See Also:
CommonQueryContract.setParameterList(QueryParameter, Object[], BindableType)
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type)
Description copied from interface:CommonQueryContract
Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the given theBindableType
.- Specified by:
setParameterList
in interfaceCommonQueryContract
- Returns:
this
, for method chaining
-
setProperties
SelectionQuery<R> setProperties(Object bean)
Description copied from interface:CommonQueryContract
Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using heuristics.- Specified by:
setProperties
in interfaceCommonQueryContract
- Parameters:
bean
- any JavaBean or POJO- Returns:
this
, for method chaining
-
setProperties
SelectionQuery<R> setProperties(Map bean)
Description copied from interface:CommonQueryContract
Bind the values of the givenMap
to named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.- Specified by:
setProperties
in interfaceCommonQueryContract
- Parameters:
bean
- aMap
of names to arguments- Returns:
this
, for method chaining
-
-