Interface Query<R>
- Type Parameters:
R- The result type, for typed queries, orObjectfor untyped queries
- All Superinterfaces:
CommonQueryContract,MutationQuery,Query,SelectionQuery<R>,TypedQuery<R>
- All Known Subinterfaces:
NativeQuery<T>,NativeQueryImplementor<R>,ProcedureCallImplementor<R>,QueryImplementor<R>,SqmQueryImplementor<R>
- All Known Implementing Classes:
AbstractQuery,NativeQueryImpl,ProcedureCallImpl,SqmQueryImpl
- a query written in HQL,
- a named query written in HQL or native SQL, or
- a criteria query.
The subtype NativeQuery represents a query written in native SQL.
This type simply mixes the TypedQuery interface defined by JPA with
SelectionQuery and MutationQuery. Unfortunately, JPA does
not distinguish between selection queries and
mutation queries, so we lose that distinction here.
However, every Query may logically be classified as one or the other.
A Query may be obtained from the Session by
calling:
QueryProducer.createQuery(String, Class), passing the HQL as a string,QueryProducer.createQuery(jakarta.persistence.criteria.CriteriaQuery), passing a criteria object, orQueryProducer.createNamedQuery(String, Class)passing the name of a query defined usingNamedQueryorNamedNativeQuery.
A Query 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.
Note that this interface offers no real advantages over SelectionQuery
except for compatibility with the JPA-defined TypedQuery interface.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddQueryHint(String hint) Add a database query hint to the SQL query.applyFetchGraph(RootGraph graph) Deprecated.applyGraph(RootGraph graph, GraphSemantic semantic) Deprecated.UsesetEntityGraph(EntityGraph, GraphSemantic)which is more type safeapplyLoadGraph(RootGraph graph) Deprecated.UsesetEntityGraph(EntityGraph, GraphSemantic)which is more type safedisableFetchProfile(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.intExecute an insert, update, or delete statement, and return the number of affected entities.Obtain the comment currently associated with this query.Deprecated, for removal: This API element is subject to removal in a future version.SinceLockOptionsis transitioning to a new role as an SPI.Get the execution options for thisQuery.The query as a string, ornullin the case of a criteria query.Execute the query and return the query results as aList.Execute the query and return the query results as aStream.Get theQueryProducerwhich produced thisQuery, that is, theSessionorStatelessSessionthat was used to create thisQueryinstance.Execute the query and return the single result of the query, throwing an exception if the query returns no results.list()Execute the query and return the query results as aList.scroll()Execute the query and return the results in a scrollable form.scroll(ScrollMode scrollMode) Execute the query and return the results in a scrollable form.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 (assumingSelectionQuery.isCacheable()).setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) setCacheStoreMode(CacheStoreMode cacheStoreMode) setComment(String comment) Set the comment for this query.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) Set the first query result row to return.setFlushMode(FlushModeType flushMode) Deprecated.setHibernateFlushMode(FlushMode flushMode) Deprecated.Set a hint.setLockMode(LockModeType lockMode) Specify the rootLockModeTypefor the querysetLockOptions(LockOptions lockOptions) Deprecated, for removal: This API element is subject to removal in a future version.setLockScope(PessimisticLockScope lockScope) Apply a scope to any pessimistic locking applied to the query.setMaxResults(int maxResults) Set the maximum number of query result rows to return.Set the page of results to return.setParameter(int parameter, Object argument) Bind the given argument to an ordinal query parameter.setParameter(int parameter, Instant argument, TemporalType temporalType) Deprecated.setParameter(int parameter, Calendar argument, TemporalType temporalType) Deprecated.setParameter(int parameter, Date argument, TemporalType temporalType) Deprecated.setParameter(int parameter, P argument, Type<P> type) Bind the given argument to an ordinal query parameter using the givenType.setParameter(int parameter, P argument, Class<P> type) Bind the given argument to an ordinal query parameter using the given Class reference to attempt to determine theTypeto use.setParameter(Parameter<Calendar> parameter, Calendar argument, TemporalType temporalType) Deprecated.setParameter(Parameter<Date> parameter, Date argument, TemporalType temporalType) Deprecated.setParameter(Parameter<T> parameter, T argument) QueryoverridesetParameter(String parameter, Object argument) Bind the given argument to a named query parameter.setParameter(String parameter, Instant argument, TemporalType temporalType) Deprecated.setParameter(String parameter, Calendar argument, TemporalType temporalType) Deprecated.setParameter(String parameter, Date argument, TemporalType temporalType) Deprecated.setParameter(String parameter, P argument, Type<P> type) Bind the given argument to a named query parameter using the givenType.setParameter(String parameter, P argument, Class<P> type) Bind the given argument to a named query parameter using the given Class reference to attempt to determine theTypeto use.setParameter(QueryParameter<P> parameter, P argument, Type<P> type) Bind an argument to the query parameter represented by the givenQueryParameterusing the givenType.setParameter(QueryParameter<P> parameter, P argument, Class<P> type) Bind an argument to the query parameter represented by the givenQueryParameterusing the given Class reference to attempt to determine theTypeto use.setParameter(QueryParameter<T> parameter, T argument) Bind an argument to the query parameter represented by the givenQueryParameter.setParameterList(int parameter, Object[] arguments) Bind multiple arguments to an ordinal query parameter.setParameterList(int parameter, Collection arguments) Bind multiple arguments to an ordinal query parameter.setParameterList(int parameter, Collection<? extends P> arguments, Type<P> type) Bind multiple arguments to an ordinal query parameter using the givenType.setParameterList(int parameter, Collection<? extends P> arguments, Class<P> javaType) Bind multiple arguments to an ordinal query parameter using the given Class reference to attempt to determine theTypeto use.setParameterList(int parameter, P[] arguments, Type<P> type) Bind multiple arguments to an ordinal query parameter using the givenType.setParameterList(int parameter, P[] arguments, Class<P> javaType) setParameterList(String parameter, Object[] values) Bind multiple arguments to a named query parameter.setParameterList(String parameter, Collection arguments) Bind multiple arguments to a named query parameter.setParameterList(String parameter, Collection<? extends P> arguments, Type<P> type) Bind multiple arguments to a named query parameter using the givenType.setParameterList(String parameter, Collection<? extends P> arguments, Class<P> javaType) Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theTypeto use.setParameterList(String parameter, P[] arguments, Type<P> type) Bind multiple arguments to a named query parameter using the givenType.setParameterList(String parameter, P[] arguments, Class<P> javaType) Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theTypeto use.setParameterList(QueryParameter<P> parameter, Collection<? extends P> arguments) Bind multiple arguments to the query parameter represented by the givenQueryParameter.setParameterList(QueryParameter<P> parameter, Collection<? extends P> arguments, Type<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, inferring theType.setParameterList(QueryParameter<P> parameter, Collection<? extends P> arguments, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the given Class reference to attempt to determine theTypeto use.setParameterList(QueryParameter<P> parameter, P[] arguments) Bind multiple arguments to the query parameter represented by the givenQueryParameter.setParameterList(QueryParameter<P> parameter, P[] arguments, Type<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, inferring theType.setParameterList(QueryParameter<P> parameter, P[] arguments, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to determine 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 givenMapfor each 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.setReadOnly(boolean readOnly) Set the read-only/modifiable mode for entities and proxies loaded by thisQuery.setResultListTransformer(ResultListTransformer<R> transformer) Set aResultListTransformer.default <T> Query<T> setResultTransformer(ResultTransformer<T> transformer) setTimeout(int timeout) Set the query timeout in seconds.setTimeout(Timeout timeout) Apply a timeout to the corresponding database query.<T> Query<T> setTupleTransformer(TupleTransformer<T> 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 an instance ofOptional.Methods inherited from interface org.hibernate.query.CommonQueryContract
getFlushMode, getHibernateFlushMode, getParameterMetadata, getQueryFlushMode, getTimeoutMethods inherited from interface jakarta.persistence.Query
getCacheRetrieveMode, getCacheStoreMode, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getTimeout, isBound, unwrapMethods inherited from interface org.hibernate.query.SelectionQuery
getCacheMode, getCacheRegion, getCacheRetrieveMode, getCacheStoreMode, getFetchSize, getFirstResult, getHibernateLockMode, getKeyedResultList, getLockMode, getMaxResults, getResultCount, getSingleResultOrNull, isCacheable, isQueryPlanCacheable, isReadOnly, setFollowOnLocking, setFollowOnStrategy, setHibernateLockMode, setLockMode, setLockScope, setQueryPlanCacheableMethods inherited from interface jakarta.persistence.TypedQuery
getSingleResultOrNull, setTimeout
-
Method Details
-
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[].- Specified by:
listin interfaceSelectionQuery<R>- Returns:
- the result 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 interfaceSelectionQuery<R>- Specified by:
getResultListin interfaceTypedQuery<R>- Returns:
- the results as a list
- Implementation Note:
- Delegates to
list()
-
scroll
ScrollableResults<R> scroll()Execute the query and return the results in a scrollable form.This overload simply calls
scroll(ScrollMode)using the dialect default scroll mode.- Specified by:
scrollin interfaceSelectionQuery<R>- See Also:
- API Note:
- The exact behavior of this method depends somewhat
on the level of JDBC driver support for scrollable
ResultSets, and so is not very portable between database.
-
scroll
Execute the query and return the results in a scrollable form. The capabilities of the returnedScrollableResultsdepend on the specifiedScrollMode.- Specified by:
scrollin interfaceSelectionQuery<R>- API Note:
- The exact behavior of this method depends somewhat
on the level of JDBC driver support for scrollable
ResultSets, and so is not very portable between database.
-
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 interfaceSelectionQuery<R>- Specified by:
getResultStreamin interfaceTypedQuery<R>- Returns:
- The results as a
Stream - Implementation Note:
- Delegates to
stream(), which in turn delegates to this method. Implementors should implement at least one of these methods.
-
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.- Specified by:
streamin interfaceSelectionQuery<R>- Returns:
- The results as a
Stream - Since:
- 5.2
-
uniqueResult
R uniqueResult()Execute the query and return the single result of the query, ornullif the query returns no results.- Specified by:
uniqueResultin interfaceSelectionQuery<R>- Returns:
- the single result or
nullif there is no result to return - 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 interfaceSelectionQuery<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
-
uniqueResultOptional
Execute the query and return the single result of the query as an instance ofOptional.- Specified by:
uniqueResultOptionalin interfaceSelectionQuery<R>- Returns:
- the single result as an
Optional - Throws:
NonUniqueResultException- if there is more than one matching result
-
executeUpdate
int executeUpdate()Execute an insert, update, or delete statement, and return the number of affected entities.For use with instances of
MutationQuerycreated usingQueryProducer.createMutationQuery(String),QueryProducer.createNamedMutationQuery(String),QueryProducer.createNativeMutationQuery(String),QueryProducer.createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate), orQueryProducer.createMutationQuery(jakarta.persistence.criteria.CriteriaDelete).- Specified by:
executeUpdatein interfaceMutationQuery- Specified by:
executeUpdatein interfaceQuery- Returns:
- the number of affected entity instances (may differ from the number of affected rows)
- See Also:
- API Note:
- This method is needed because this interface extends
Query, which defines this method. SeeMutationQueryandSelectionQuery.
-
getSession
SharedSessionContract getSession()Get theQueryProducerwhich produced thisQuery, that is, theSessionorStatelessSessionthat was used to create thisQueryinstance.- Returns:
- The producer of this query
-
getQueryString
String getQueryString()The query as a string, ornullin the case of a criteria query. -
applyGraph
Deprecated.UsesetEntityGraph(EntityGraph, GraphSemantic)which is more type safeApply the given graph using the given semantic- Parameters:
graph- The graph to apply.semantic- The semantic to use when applying the graph
-
applyFetchGraph
Deprecated.UsesetEntityGraph(EntityGraph, GraphSemantic)which is more type safeApply the given graph using fetch semantics.- API Note:
- This method calls
applyGraph(RootGraph, GraphSemantic)usingGraphSemantic.FETCHas the semantic.
-
applyLoadGraph
Deprecated.UsesetEntityGraph(EntityGraph, GraphSemantic)which is more type safeApply the given graph using load semantics.- API Note:
- This method calls
applyGraph(RootGraph, GraphSemantic)usingGraphSemantic.LOADas the semantic.
-
getComment
String getComment()Obtain the comment currently associated with 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:
getCommentin interfaceCommonQueryContract- Returns:
- The comment.
-
setComment
Set 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 interfaceMutationQuery- Specified by:
setCommentin interfaceSelectionQuery<R>- Parameters:
comment- The human-readable comment- Returns:
this, for method chaining- See Also:
-
addQueryHint
Add a database query hint to the SQL query.A database hint is a completely different concept to a JPA hint specified using
QueryHintorQuery.getHints(). These are hints to the JPA provider.Multiple query hints may be specified. The operation
Dialect.getQueryHintString(String, List)determines how the hint is actually added to the SQL query.- Parameters:
hint- The database specific query hint to add.
-
getLockOptions
Deprecated, for removal: This API element is subject to removal in a future version.SinceLockOptionsis transitioning to a new role as an SPI.Obtains theLockOptionsin effect for this query.- Specified by:
getLockOptionsin interfaceSelectionQuery<R>- Returns:
- The
LockOptionscurrently in effect - See Also:
-
setLockOptions
Deprecated, for removal: This API element is subject to removal in a future version.Apply the given lock options to this query. Alias-specific lock modes in the given lock options are merged with any alias-specific lock mode which have already been set. If a lock mode has already been specified for an alias that is among the aliases in the given lock options, the lock mode specified in the given lock options overrides the lock mode that was already set.- Parameters:
lockOptions- The lock options to apply to the query.- Returns:
this, for method chaining- See Also:
-
setTimeout
Apply a timeout to the corresponding database query.- Specified by:
setTimeoutin interfaceCommonQueryContract- Parameters:
timeout- The timeout to apply- Returns:
this, for method chaining
-
setLockScope
Apply a scope to any pessimistic locking applied to the query.- Specified by:
setLockScopein interfaceSelectionQuery<R>- Parameters:
lockScope- The lock scope to apply- Returns:
this, for method chaining
-
setTupleTransformer
Set aTupleTransformer.- Specified by:
setTupleTransformerin interfaceSelectionQuery<R>
-
setResultListTransformer
Set aResultListTransformer.- Specified by:
setResultListTransformerin interfaceSelectionQuery<R>
-
getQueryOptions
QueryOptions getQueryOptions()Get the execution options for thisQuery. Many of the setters of this object update the state of the returnedQueryOptions. This is useful because it gives access to s primitive value in its (nullable) wrapper form, rather than the primitive form as required by JPA. This allows us to distinguish whether a value has been explicitly set by the client.- Returns:
- Return the encapsulation of this query's options.
-
setParameter
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 accept a "type".
- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Bind the given argument to a named query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameter(String, Object)is used.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- See Also:
-
setParameter
Bind the given argument to a named query parameter using the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>
-
setParameter
@Deprecated(since="7") Query<R> setParameter(String parameter, Instant argument, TemporalType temporalType) Deprecated.Bind anInstantvalue to the named query parameter using just the portion indicated by the givenTemporalType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>
-
setParameter
@Deprecated(since="7") Query<R> setParameter(String parameter, Calendar argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated(since="7") Query<R> setParameter(String parameter, Date argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
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:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
Bind the given argument to an ordinal query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameter(int, Object)is used.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- See Also:
-
setParameter
Bind the given argument to an ordinal query parameter using the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>
-
setParameter
@Deprecated(since="7") Query<R> setParameter(int parameter, Instant argument, TemporalType temporalType) Deprecated.Bind anInstantvalue to the ordinal query parameter using just the portion indicated by the givenTemporalType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>
-
setParameter
@Deprecated(since="7") Query<R> setParameter(int parameter, Date argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated(since="7") Query<R> setParameter(int parameter, Calendar argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
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:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Parameters:
parameter- the query parameter mementoargument- the argument, which might be null- Returns:
this, for method chaining- See Also:
-
setParameter
Bind an argument to the query parameter represented by the givenQueryParameterusing the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameter(QueryParameter, Object)is used- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Parameters:
parameter- the query parameter mementoargument- the argument, which might be nulltype- aTyperepresenting the type of the parameter- Returns:
this, for method chaining- See Also:
-
setParameter
Bind an argument to the query parameter represented by the givenQueryParameterusing the givenType.- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Parameters:
parameter- the query parameter mementoargument- the argument, which might be nulltype- anTyperepresenting the type of the parameter- Returns:
this, for method chaining
-
setParameter
Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated(since="7") Query<R> setParameter(Parameter<Calendar> parameter, Calendar argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameter
@Deprecated(since="7") Query<R> setParameter(Parameter<Date> parameter, Date argument, TemporalType temporalType) Deprecated.Queryoverride- Specified by:
setParameterin interfaceCommonQueryContract- Specified by:
setParameterin interfaceMutationQuery- Specified by:
setParameterin interfaceQuery- Specified by:
setParameterin interfaceSelectionQuery<R>- Specified by:
setParameterin interfaceTypedQuery<R>- See Also:
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
<P> Query<R> setParameterList(String parameter, Collection<? extends P> arguments, Class<P> javaType) Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to a named query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to a named query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to an ordinal query parameter using the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to an ordinal query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to an ordinal query parameter using the givenType.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Parameters:
parameter- the parameter mementoarguments- a collection of arguments- Returns:
this, for method chaining
-
setParameterList
<P> Query<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> arguments, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the given Class reference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression such
as
entity.field in (:values).
-
setParameterList
<P> Query<R> setParameterList(QueryParameter<P> parameter, Collection<? extends P> arguments, Type<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, inferring theType.The "type mapping" for the binding is inferred from the type of the first collection element.
- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression such
as
entity.field in (:values).
-
setParameterList
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:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Parameters:
parameter- the parameter mementoarguments- a collection of arguments- Returns:
this, for method chaining
-
setParameterList
Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to determine theTypeto use. If unable to determine an appropriateType,setParameterList(String, Collection)is used.- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- See Also:
- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setParameterList
Bind multiple arguments to the query parameter represented by the givenQueryParameter, inferring theType.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterListin interfaceCommonQueryContract- Specified by:
setParameterListin interfaceMutationQuery- Specified by:
setParameterListin interfaceSelectionQuery<R>- Returns:
this, for method chaining- API Note:
- This is used for binding a list of values to an expression
such as
entity.field in (:values).
-
setProperties
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:
setPropertiesin interfaceCommonQueryContract- Specified by:
setPropertiesin interfaceMutationQuery- Specified by:
setPropertiesin interfaceSelectionQuery<R>- Parameters:
bean- any JavaBean or POJO- Returns:
this, for method chaining
-
setProperties
Bind the values of the givenMapfor each 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 interfaceMutationQuery- Specified by:
setPropertiesin interfaceSelectionQuery<R>- Parameters:
bean- aMapof names to arguments- Returns:
this, for method chaining
-
setHibernateFlushMode
Deprecated.Description copied from interface:CommonQueryContractSet the currentFlushModein effect for this query.- Specified by:
setHibernateFlushModein interfaceCommonQueryContract- Specified by:
setHibernateFlushModein interfaceMutationQuery- Specified by:
setHibernateFlushModein interfaceSelectionQuery<R>- See Also:
-
setQueryFlushMode
Description copied from interface:CommonQueryContractSet theQueryFlushModeto use for this query.- Specified by:
setQueryFlushModein interfaceCommonQueryContract- Specified by:
setQueryFlushModein interfaceMutationQuery- Specified by:
setQueryFlushModein interfaceSelectionQuery<R>- See Also:
-
setCacheable
Description copied from interface:SelectionQueryEnable/disable second level query (result) caching for this query.- Specified by:
setCacheablein interfaceSelectionQuery<R>- See Also:
-
setCacheRegion
Description copied from interface:SelectionQuerySet the name of the cache region where query results should be cached (assumingSelectionQuery.isCacheable()).nullindicates to use the default region.- Specified by:
setCacheRegionin interfaceSelectionQuery<R>- See Also:
-
setCacheMode
Description copied from interface:SelectionQuerySet the currentCacheModein effect for this query.Set it to
nullto indicate that theCacheModeof thesessionshould be used.- Specified by:
setCacheModein interfaceSelectionQuery<R>- See Also:
-
setCacheStoreMode
- Specified by:
setCacheStoreModein interfaceQuery- Specified by:
setCacheStoreModein interfaceSelectionQuery<R>- Specified by:
setCacheStoreModein interfaceTypedQuery<R>- See Also:
-
setCacheRetrieveMode
- Specified by:
setCacheRetrieveModein interfaceQuery- Specified by:
setCacheRetrieveModein interfaceSelectionQuery<R>- Specified by:
setCacheRetrieveModein interfaceTypedQuery<R>- See Also:
-
setTimeout
Description copied from interface:CommonQueryContractSet 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, although certain "magic values" are handled - see Timeouts.NO_WAIT.
A value of zero indicates no timeout.
- Specified by:
setTimeoutin interfaceCommonQueryContract- Specified by:
setTimeoutin interfaceMutationQuery- Specified by:
setTimeoutin interfaceSelectionQuery<R>- Parameters:
timeout- the timeout in seconds- Returns:
this, for method chaining- See Also:
-
setFetchSize
Description copied from interface:SelectionQuerySets a JDBC fetch size hint for the query.- Specified by:
setFetchSizein interfaceSelectionQuery<R>- Parameters:
fetchSize- the fetch size hint- Returns:
this, for method chaining- See Also:
-
setReadOnly
Description copied from interface:SelectionQuerySet 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 interfaceSelectionQuery<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
Description copied from interface:SelectionQuerySet the maximum number of query result rows to return.- Specified by:
setMaxResultsin interfaceQuery- Specified by:
setMaxResultsin interfaceSelectionQuery<R>- Specified by:
setMaxResultsin interfaceTypedQuery<R>- Parameters:
maxResults- the maximum length of the query result list
-
setFirstResult
Description copied from interface:SelectionQuerySet the first query result row to return. The very first row of the query result list is considered the zeroth row.- Specified by:
setFirstResultin interfaceQuery- Specified by:
setFirstResultin interfaceSelectionQuery<R>- Specified by:
setFirstResultin interfaceTypedQuery<R>- Parameters:
startPosition- the position of the first row to return, indexed from zero
-
setPage
Description copied from interface:SelectionQuerySet the page of results to return.- Specified by:
setPagein interfaceSelectionQuery<R>- See Also:
-
setHint
Description copied from interface:CommonQueryContractSet a hint. The hints understood by Hibernate are enumerated byAvailableHints.- Specified by:
setHintin interfaceCommonQueryContract- Specified by:
setHintin interfaceMutationQuery- Specified by:
setHintin interfaceQuery- Specified by:
setHintin interfaceSelectionQuery<R>- Specified by:
setHintin interfaceTypedQuery<R>- See Also:
-
setEntityGraph
Description copied from interface:SelectionQueryApply anEntityGraphto the query.This is an alternative way to specify the associations which should be fetched as part of the initial query.
- Specified by:
setEntityGraphin interfaceSelectionQuery<R>
-
enableFetchProfile
Description copied from interface:SelectionQueryEnable 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.
- Specified by:
enableFetchProfilein interfaceSelectionQuery<R>- Parameters:
profileName- the name of the fetch profile to be enabled- See Also:
-
disableFetchProfile
Description copied from interface:SelectionQueryDisable the fetch profile with the given name in this session. If the fetch profile is not currently enabled, the call has no effect.- Specified by:
disableFetchProfilein interfaceSelectionQuery<R>- Parameters:
profileName- the name of the fetch profile to be disabled- See Also:
-
setFlushMode
Deprecated.Description copied from interface:CommonQueryContractSet theFlushModeto use for this query.Setting this to
nullultimately indicates to use theFlushModeof the session. UseCommonQueryContract.setHibernateFlushMode(org.hibernate.FlushMode)passingFlushMode.MANUALinstead to indicate that no automatic flushing should occur.- Specified by:
setFlushModein interfaceCommonQueryContract- Specified by:
setFlushModein interfaceMutationQuery- Specified by:
setFlushModein interfaceQuery- Specified by:
setFlushModein interfaceSelectionQuery<R>- Specified by:
setFlushModein interfaceTypedQuery<R>- See Also:
-
setLockMode
Description copied from interface:SelectionQuerySpecify the rootLockModeTypefor the query- Specified by:
setLockModein interfaceQuery- Specified by:
setLockModein interfaceSelectionQuery<R>- Specified by:
setLockModein interfaceTypedQuery<R>- See Also:
-
setResultTransformer
@Deprecated(since="5.2") default <T> Query<T> setResultTransformer(ResultTransformer<T> transformer)
-
setEntityGraph(EntityGraph, GraphSemantic)which is more type safe