Interface SelectionQuery<R>
- All Superinterfaces:
CommonQueryContract, Query, Query<R>, TypedQuery<R>
- All Known Subinterfaces:
NativeQuery<T>, NativeQueryImplementor<R>, SelectionQueryImplementor<R>
select. It is a slimmed-down version of Query, providing
only methods relevant to selection queries.
A SelectionQuery may be obtained from the Session
by calling:
SharedSessionContract.createSelectionQuery(String, Class), passing the HQL as a string,SharedSessionContract.createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery), passing a criteria query object, orSharedSessionContract.createNamedSelectionQuery(String, Class)passing the name of a query defined usingNamedQueryorNamedNativeQuery.
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.
getResultList():
List<Book> books =
session.createSelectionQuery("from Book left join fetch authors where title like :title")
.setParameter("title", title)
.setMaxResults(50)
.getResultList();
A query which is expected to return exactly one on result should be executed
via getSingleResult(), or, if it might not return a result,
getSingleResultOrNull():
Book book =
session.createSelectionQuery("from Book where isbn = ?1")
.setParameter(1, isbn)
.getSingleResultOrNull();
A query may have explicit fetch joins, specified using the syntax
join fetch in HQL, or via FetchParent.fetch(SingularAttribute)
in the criteria API. Additional fetch joins may be added by:
- setting an
EntityGraphby 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, three alternative approaches to pagination are available:
-
The ancient but dependable operations
setFirstResult(int)andsetMaxResults(int)are the standard approach blessed by the JPA specification. -
SelectionSpecificationandsetPage(Page), together withOrderandPage, provide a streamlined API for offset-based pagination, at a slightly higher semantic level. -
On the other hand,
KeyedPageandKeyedResultList, 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
Modifier and TypeMethodDescriptiondisableFetchProfile(String profileName) Disable the fetch profile with the given name in this session.enableFetchProfile(String profileName) Enable the fetch profile with the given name during execution of this query.Obtain theCacheModein effect for this query.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).Obtain the JDBC fetch size hint in effect for this query.Get the rootLockModefor the querygetKeyedResultList(KeyedPage<R> page) Execute the query and return the results for the given page, using key-based pagination.longDetermine the size of the query result list that would be returned by callinggetResultList()with no offset or limit applied to the query.Execute the query and return the query results as aList.Execute the query and return the query results as aStream.The type of things returned from the query.Execute the query and return the single result of the query, throwing an exception if the query returns no results.Execute the query and return the single result of the query, ornullif the query returns no results.booleanShould the results of the query be stored in the second level cache?booleanShould the query plan of the query be stored in the query plan cache?booleanShould 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()Execute the query and return the query results as aList.scroll()Returns scrollable access to the query results, using the default scroll mode of the SQL dialect.scroll(ScrollMode scrollMode) Returns scrollable access to the query results.setCacheable(boolean cacheable) Enable/disable second level query (result) caching for this query.setCacheMode(CacheMode cacheMode) Set the currentCacheModein effect for this query.setCacheRegion(String cacheRegion) Set the name of the cache region where query results should be cached (assumingisCacheable()).setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) setCacheStoreMode(CacheStoreMode cacheStoreMode) setComment(String comment) Set the comment for this query.<P> SelectionQuery<R> setConvertedParameter(int position, P value, Class<? extends AttributeConverter<P, ?>> converter) <P> SelectionQuery<R> setConvertedParameter(String name, P value, Class<? extends AttributeConverter<P, ?>> converter) default SelectionQuery<R> setEntityGraph(EntityGraph<? super R> entityGraph) Apply anEntityGraphto the query using load graph semantics.setEntityGraph(EntityGraph<? super R> graph, GraphSemantic semantic) Apply anEntityGraphto the query.setFetchSize(int fetchSize) Sets a JDBC fetch size hint for the query.setFirstResult(int startPosition) setFlushMode(FlushModeType flushMode) Set theFlushModeTypeto use for this query.setFollowOnStrategy(Locking.FollowOn followOnStrategy) Specifies whether follow-on locking should be appliedsetHibernateLockMode(LockMode lockMode) Specify the rootLockModefor the querySet a hint.setLockMode(LockModeType lockMode) setLockScope(PessimisticLockScope lockScope) Apply a scope to any pessimistic locking applied to the query.setLockTimeout(Timeout lockTimeout) Set a timeout to be applied specifically to pessimistic lock acquisition.setMaxResults(int maxResults) Set the page of results to return.setParameter(int position, Object value) Bind the given argument to an ordinal query parameter.setParameter(int position, Instant value, TemporalType temporalType) Deprecated.setParameter(int position, Calendar value, TemporalType temporalType) Deprecated.setParameter(int position, Date value, TemporalType temporalType) Deprecated.<P> SelectionQuery<R> setParameter(int position, P value, Type<P> type) Bind the given argument to an ordinal query parameter using the givenType.<P> SelectionQuery<R> setParameter(int position, P value, Class<P> type) setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Deprecated.setParameter(Parameter<Date> param, Date value, TemporalType temporalType) Deprecated.<T> SelectionQuery<R> setParameter(Parameter<T> param, T value) setParameter(String name, Object value) Bind the given argument to a named query parameter.setParameter(String name, Instant value, TemporalType temporalType) Deprecated.setParameter(String name, Calendar value, TemporalType temporalType) Deprecated.setParameter(String name, Date value, TemporalType temporalType) Deprecated.<P> SelectionQuery<R> setParameter(String name, P value, Type<P> type) Bind the given argument to a named query parameter using the givenType.<P> SelectionQuery<R> setParameter(String name, P value, Class<P> type) <P> SelectionQuery<R> setParameter(QueryParameter<P> parameter, P val, Type<P> type) Bind an argument to the query parameter represented by the givenQueryParameter, using the givenType.<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 givenClassreference to attempt to infer theTypeto use.<T> SelectionQuery<R> setParameter(QueryParameter<T> parameter, T value) Bind an argument to the query parameter represented by the givenQueryParameter.setParameterList(int position, Object[] values) Bind multiple arguments to an ordinal query parameter.setParameterList(int position, Collection values) Bind multiple arguments to an ordinal query parameter.<P> SelectionQuery<R> setParameterList(int position, Collection<? extends P> values, Type<P> type) Bind multiple arguments to an ordinal query parameter using the givenType.<P> SelectionQuery<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaType) <P> SelectionQuery<R> setParameterList(int position, P[] values, Type<P> type) Bind multiple arguments to an ordinal query parameter using the givenType.<P> SelectionQuery<R> setParameterList(int position, P[] values, Class<P> javaType) setParameterList(String name, Object[] values) Bind multiple arguments to a named query parameter.setParameterList(String name, Collection values) Bind multiple arguments to a named query parameter.<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, Type<P> type) Bind multiple arguments to a named query parameter using the givenType.<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to a named query parameter using the givenClassreference to attempt to infer theTypeIf unable to infer an appropriateType, fall back toCommonQueryContract.setParameterList(String, Collection).<P> SelectionQuery<R> setParameterList(String name, P[] values, Type<P> type) Bind multiple arguments to a named query parameter using the givenType.<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 theTypeto use.<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, Type<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, using the givenType.<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theTypeto use.<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, Type<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, using the given theType.<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theTypeto use.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.setProperties(Map bean) Bind the values of the givenMapto named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.setQueryFlushMode(QueryFlushMode queryFlushMode) Set theQueryFlushModeto use for this query.setQueryPlanCacheable(boolean queryPlanCacheable) Enable/disable query plan caching for this query.setReadOnly(boolean readOnly) Set the read-only/modifiable mode for entities and proxies loaded by thisQuery.setResultListTransformer(ResultListTransformer<R> transformer) Set aResultListTransformer.setTimeout(int timeout) Apply a timeout to the corresponding database query.setTimeout(Timeout timeout) Apply a timeout to the corresponding database query.setTimeout(Integer timeout) Apply a timeout to the corresponding database query.<X> SelectionQuery<X> setTupleTransformer(TupleTransformer<X> transformer) Set aTupleTransformer.stream()Execute the query and return the query results as aStream.Execute the query and return the single result of the query, ornullif the query returns no results.Execute the query and return the single result of the query, as anOptional.Methods inherited from interface CommonQueryContract
asMutationQuery, asSelectionQuery, asSelectionQuery, asSelectionQuery, getComment, getEffectiveFlushMode, getParameterMetadata, getQueryFlushMode, getSession, getTimeoutMethods inherited from interface Query
getHints, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrapMethods inherited from interface Query
addQueryHint, asSelectionQuery, asStatement, executeUpdate, getFlushMode, getLockTimeout, getQueryOptions, getQueryString, ofType, setFollowOnLockingStrategy, withEntityGraphMethods inherited from interface TypedQuery
executeUpdate, getEntityGraph, getFirstResult, getLockScope, getMaxResults
-
Method Details
-
getResultType
-
list
-
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[].- Specified by:
getResultListin interfaceQuery- Specified by:
getResultListin interfaceQuery<R>- Specified by:
getResultListin interfaceTypedQuery<R>- Returns:
- the results as a list
- API Note:
- Synonym for
list()
-
scroll
ScrollableResults<R> scroll()Returns scrollable access to the query results, using the default scroll mode of the SQL dialect. -
scroll
Returns scrollable access to the query results. The capabilities of the returnedScrollableResultsdepend on the specifiedScrollMode. -
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.- Specified by:
getResultStreamin interfaceQuery- Specified by:
getResultStreamin interfaceQuery<R>- Specified by:
getResultStreamin interfaceTypedQuery<R>- Returns:
- The results as a
Stream - API Note:
- Synonym for
stream()
-
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. -
uniqueResult
R uniqueResult()Execute the query and return the single result of the query, ornullif the query returns no results.- Specified by:
uniqueResultin interfaceQuery<R>- 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.- Specified by:
getSingleResultin interfaceQuery- Specified by:
getSingleResultin interfaceQuery<R>- Specified by:
getSingleResultin interfaceTypedQuery<R>- 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, ornullif the query returns no results.- Specified by:
getSingleResultOrNullin interfaceQuery- Specified by:
getSingleResultOrNullin interfaceTypedQuery<R>- Returns:
- the single result or
nullif there is no result to return - Throws:
NonUniqueResultException- if there is more than one matching result- Since:
- 6.0
-
uniqueResultOptional
Execute the query and return the single result of the query, as anOptional.- Specified by:
uniqueResultOptionalin interfaceQuery<R>- Returns:
- the single result as an
Optional - Throws:
NonUniqueResultException- if there is more than one matching result
-
getResultCount
Determine the size of the query result list that would be returned by callinggetResultList()with no offset or limit applied to the query.- Specified by:
getResultCountin interfaceTypedQuery<R>- Returns:
- the size of the list that would be returned
- Since:
- 6.5
-
getKeyedResultList
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:
-
setHint
Description copied from interface:QuerySet a hint. Hints are a JPA-standard way to control provider-specific behavior affecting execution of the query. Clients of native Hibernate API should make use of type-safe operations of this interface and of its subtypes. For example,setCacheRegion(String)is preferred overHibernateHints.HINT_CACHE_REGION.The hints understood by Hibernate are enumerated by
AvailableHints.- Specified by:
setHintin interfaceCommonQueryContract- Specified by:
setHintin interfaceQuery- Specified by:
setHintin interfaceQuery<R>- Specified by:
setHintin interfaceTypedQuery<R>- See Also:
-
setEntityGraph
Apply anEntityGraphto the query using load graph semantics. Covariant override of TypedQuery.setEntityGraph(EntityGraph)This is an alternative way to specify the associations which should be fetched as part of the initial query.
- Specified by:
setEntityGraphin interfaceTypedQuery<R>- Since:
- 6.3
- See Also:
-
setEntityGraph
Apply anEntityGraphto the query.This is an alternative way to specify the associations which should be fetched as part of the initial query.
- Since:
- 6.3
- See Also:
-
enableFetchProfile
Enable the fetch profile with the given name during execution of 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:
-
disableFetchProfile
Disable the fetch profile with the given name in this session. If the 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:
-
setFlushMode
Description copied from interface:QuerySet theFlushModeTypeto use for this query.Setting this to
nullultimately indicates to use theFlushModeof the session. UseQuery.setQueryFlushMode(QueryFlushMode)passingQueryFlushMode.NO_FLUSHinstead to indicate that no automatic flushing should occur.- Specified by:
setFlushModein interfaceQuery- Specified by:
setFlushModein interfaceQuery<R>- Specified by:
setFlushModein interfaceTypedQuery<R>- See Also:
-
setQueryFlushMode
Description copied from interface:CommonQueryContractSet theQueryFlushModeto use for this query.- Specified by:
setQueryFlushModein interfaceCommonQueryContract- Specified by:
setQueryFlushModein interfaceQuery<R>- See Also:
-
setTimeout
Description copied from interface:QueryApply a timeout to the corresponding database query.- Specified by:
setTimeoutin interfaceCommonQueryContract- Specified by:
setTimeoutin interfaceQuery<R>- See Also:
-
setTimeout
Description copied from interface:QueryApply a timeout to the corresponding database query.- Specified by:
setTimeoutin interfaceCommonQueryContract- Specified by:
setTimeoutin interfaceQuery- Specified by:
setTimeoutin interfaceQuery<R>- Specified by:
setTimeoutin interfaceTypedQuery<R>- See Also:
-
setTimeout
Description copied from interface:QueryApply a timeout to the corresponding database query.- Specified by:
setTimeoutin interfaceCommonQueryContract- Specified by:
setTimeoutin interfaceQuery- Specified by:
setTimeoutin interfaceQuery<R>- Specified by:
setTimeoutin interfaceTypedQuery<R>
-
setComment
Description copied from interface:QuerySet the comment for this query.If SQL commenting is enabled, the comment will be added to the SQL query sent to the database, which may be useful for identifying the source of troublesome queries.
SQL commenting may be enabled using the configuration property "hibernate.use_sql_comments".
- Specified by:
setCommentin interfaceCommonQueryContract- Specified by:
setCommentin interfaceQuery<R>- See Also:
-
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.- Specified by:
getFetchSizein interfaceQuery<R>- Returns:
- The timeout in seconds
- See Also:
- 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
ResultSetprocessing .
-
setFetchSize
Sets a JDBC fetch size hint for the query.- Specified by:
setFetchSizein interfaceQuery<R>- Parameters:
fetchSize- the fetch size hint- Returns:
this, for method chaining- See Also:
-
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.- Specified by:
isReadOnlyin interfaceQuery<R>- Returns:
trueif the entities and proxies loaded by the query will be put in read-only mode;falseotherwise (they will be modifiable)- See Also:
-
setReadOnly
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.
- Specified by:
setReadOnlyin interfaceQuery<R>- Parameters:
readOnly-trueindicates that entities and proxies loaded by the query are to be put in read-only mode;falseindicates that entities and proxies loaded by the query will be put in modifiable mode- Returns:
this, for method chaining
-
setMaxResults
- Specified by:
setMaxResultsin interfaceQuery- Specified by:
setMaxResultsin interfaceQuery<R>- Specified by:
setMaxResultsin interfaceTypedQuery<R>
-
setFirstResult
- Specified by:
setFirstResultin interfaceQuery- Specified by:
setFirstResultin interfaceQuery<R>- Specified by:
setFirstResultin interfaceTypedQuery<R>
-
setPage
Set the page of results to return.- Since:
- 6.3
- See Also:
-
getCacheMode
CacheMode getCacheMode()Obtain theCacheModein effect for this query. By default, the query inherits theCacheModeof the session from which it originates.The
CacheModehere affects the use of entity and collection caches as the query result set is processed. For caching of the actual query results, useisCacheable()andgetCacheRegion().In order for this setting to have any affect, second-level caching must be enabled and the entities and collections must be eligible for storage in the second-level cache.
- Specified by:
getCacheModein interfaceQuery<R>- See Also:
-
getCacheStoreMode
CacheStoreMode getCacheStoreMode()- Specified by:
getCacheStoreModein interfaceQuery- Specified by:
getCacheStoreModein interfaceTypedQuery<R>- Since:
- 6.2
- See Also:
-
getCacheRetrieveMode
CacheRetrieveMode getCacheRetrieveMode()- Specified by:
getCacheRetrieveModein interfaceQuery- Specified by:
getCacheRetrieveModein interfaceTypedQuery<R>- Since:
- 6.2
- See Also:
-
setCacheMode
Set the currentCacheModein effect for this query.Set it to
nullto indicate that theCacheModeof thesessionshould be used.- Specified by:
setCacheModein interfaceQuery<R>- See Also:
-
setCacheStoreMode
- Specified by:
setCacheStoreModein interfaceQuery- Specified by:
setCacheStoreModein interfaceQuery<R>- Specified by:
setCacheStoreModein interfaceTypedQuery<R>- Since:
- 6.2
- See Also:
-
setCacheRetrieveMode
- Specified by:
setCacheRetrieveModein interfaceQuery- Specified by:
setCacheRetrieveModein interfaceQuery<R>- Specified by:
setCacheRetrieveModein interfaceTypedQuery<R>- Since:
- 6.2
- See Also:
-
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
SessionFactoryfor this to happen. Usually that is controlled by the configuration setting "hibernate.cache.use_query_cache".- Specified by:
isCacheablein interfaceQuery<R>
-
setCacheable
Enable/disable second level query (result) caching for this query.- Specified by:
setCacheablein interfaceQuery<R>- See Also:
-
isQueryPlanCacheable
boolean isQueryPlanCacheable()Should the query plan of the query be stored in the query plan cache?- Specified by:
isQueryPlanCacheablein interfaceQuery<R>
-
setQueryPlanCacheable
Enable/disable query plan caching for this query.- Specified by:
setQueryPlanCacheablein interfaceQuery<R>- See Also:
-
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).nullindicates that the default region should be used.- Specified by:
getCacheRegionin interfaceQuery<R>
-
setCacheRegion
Set the name of the cache region where query results should be cached (assumingisCacheable()).nullindicates to use the default region.- Specified by:
setCacheRegionin interfaceQuery<R>- See Also:
-
getLockMode
LockModeType getLockMode()- Specified by:
getLockModein interfaceQuery- Specified by:
getLockModein interfaceTypedQuery<R>- See Also:
-
setLockMode
- Specified by:
setLockModein interfaceQuery- Specified by:
setLockModein interfaceQuery<R>- Specified by:
setLockModein interfaceTypedQuery<R>- See Also:
-
getHibernateLockMode
LockMode getHibernateLockMode()Get the rootLockModefor the query- Specified by:
getHibernateLockModein interfaceQuery<R>- See Also:
-
setHibernateLockMode
Specify the rootLockModefor the query- Specified by:
setHibernateLockModein interfaceQuery<R>- See Also:
-
setLockScope
Apply a scope to any pessimistic locking applied to the query.- Specified by:
setLockScopein interfaceQuery<R>- Specified by:
setLockScopein interfaceTypedQuery<R>- Parameters:
lockScope- The lock scope to apply- Returns:
this, for method chaining
-
setLockTimeout
Description copied from interface:QuerySet a timeout to be applied specifically to pessimistic lock acquisition.- Specified by:
setLockTimeoutin interfaceQuery<R>- See Also:
-
setFollowOnStrategy
Specifies whether follow-on locking should be applied- Specified by:
setFollowOnStrategyin interfaceQuery<R>- Parameters:
followOnStrategy- The strategy for follow-on locking.- Returns:
this, for method chaining
-
setTupleTransformer
Set aTupleTransformer.- Specified by:
setTupleTransformerin interfaceQuery<R>
-
setResultListTransformer
Set aResultListTransformer.- Specified by:
setResultListTransformerin interfaceQuery<R>
-
setParameter
Description copied from interface:QueryBind 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 overloads which accepts a "type", or pass a
TypedParameterValue.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Description copied from interface:QueryBind the given argument to a named query parameter using the givenClassreference to attempt to infer theType. If unable to infer an appropriateType, fall back toCommonQueryContract.setParameter(String, Object).- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Description copied from interface:QueryBind the given argument to a named query parameter using the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>
-
setParameter
Description copied from interface:QueryBind 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 overloads which accepts a "type", or pass a
TypedParameterValue.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Description copied from interface:QueryBind the given argument to an ordinal query parameter using the givenClassreference to attempt to infer theType. If unable to infer an appropriateType, fall back toCommonQueryContract.setParameter(int, Object).- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Description copied from interface:QueryBind the given argument to an ordinal query parameter using the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>
-
setParameter
Description copied from interface:QueryBind 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 overloads which accepts a "type".
- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery<R>- Parameters:
parameter- the query parameter mementovalue- the argument, which might be null- Returns:
this, for method chaining- See Also:
-
setParameter
Description copied from interface:QueryBind an argument to the query parameter represented by the givenQueryParameter, using the givenClassreference to attempt to infer theTypeto use. If unable to infer an appropriateType, fall back toCommonQueryContract.setParameter(QueryParameter, Object).- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery<R>- Parameters:
parameter- the query parameter mementovalue- the argument, which might be nulltype- aTyperepresenting the type of the parameter- Returns:
this, for method chaining- See Also:
-
setParameter
Description copied from interface:QueryBind an argument to the query parameter represented by the givenQueryParameter, using the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery<R>- Parameters:
parameter- the query parameter mementoval- the argument, which might be nulltype- aTyperepresenting the type of the parameter- Returns:
this, for method chaining
-
setParameter
Description copied from interface:Query- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setProperties
Description copied from interface:QueryBind 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:
setPropertiesin interfaceCommonQueryContract- Specified by:
setPropertiesin interfaceQuery<R>- Parameters:
bean- any JavaBean or POJO- Returns:
this, for method chaining
-
setProperties
Description copied from interface:QueryBind the values of the givenMapto named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.- Specified by:
setPropertiesin interfaceCommonQueryContract- Specified by:
setPropertiesin interfaceQuery<R>- Parameters:
bean- aMapof names to arguments- Returns:
this, for method chaining
-
setConvertedParameter
<P> SelectionQuery<R> setConvertedParameter(String name, P value, Class<? extends AttributeConverter<P, ?>> converter) Description copied from interface:Query- Specified by:
setConvertedParameterin interfaceCommonQueryContract- Specified by:
setConvertedParameterin interfaceQuery- Specified by:
setConvertedParameterin interfaceQuery<R>- Specified by:
setConvertedParameterin interfaceTypedQuery<R>- See Also:
-
setConvertedParameter
<P> SelectionQuery<R> setConvertedParameter(int position, P value, Class<? extends AttributeConverter<P, ?>> converter) Description copied from interface:Query- Specified by:
setConvertedParameterin interfaceCommonQueryContract- Specified by:
setConvertedParameterin interfaceQuery- Specified by:
setConvertedParameterin interfaceQuery<R>- Specified by:
setConvertedParameterin interfaceTypedQuery<R>- See Also:
-
setParameterList
Description copied from interface:QueryBind 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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
<P> SelectionQuery<R> setParameterList(String name, Collection<? extends P> values, Class<P> javaType) Description copied from interface:QueryBind multiple arguments to a named query parameter using the givenClassreference to attempt to infer theTypeIf unable to infer an appropriateType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:QueryBind multiple arguments to a named query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind 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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind multiple arguments to a named query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,CommonQueryContract.setParameterList(String, Collection)is used- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:QueryBind multiple arguments to a named query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind 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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
<P> SelectionQuery<R> setParameterList(int position, Collection<? extends P> values, Class<P> javaType) Description copied from interface:QueryBind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theType. If unable to infer an appropriateType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:QueryBind multiple arguments to an ordinal query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind 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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theType. If unable to infer an appropriateType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:QueryBind multiple arguments to an ordinal query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind 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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- 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:QueryBind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theTypeto use. If unable to infer an appropriateType, fall back to usingCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
<P> SelectionQuery<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Type<P> type) Description copied from interface:QueryBind multiple arguments to the query parameter represented by the givenQueryParameter, using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind 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
QueryParameterand the type of the first given argument.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Parameters:
parameter- the parameter mementovalues- a collection of arguments- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:QueryBind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theTypeto use. If unable to infer an appropriateType, fall back to usingCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:QueryBind multiple arguments to the query parameter represented by the givenQueryParameter, using the given theType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceQuery<R>- Returns:
this, for method chaining
-
setParameter
Deprecated.Description copied from interface:QueryBind anInstantvalue to the named Queryparameter using just the portion indicated by the given TemporalType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery<R>
-
setParameter
Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Deprecated.Description copied from interface:QueryBind anInstantvalue to the ordinal Queryparameter using just the portion indicated by the given TemporalType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery<R>
-
setParameter
Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated SelectionQuery<R> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated SelectionQuery<R> setParameter(Parameter<Date> param, Date value, TemporalType temporalType) Deprecated.Description copied from interface:QueryQueryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-