Interface CommonQueryContract
- All Known Subinterfaces:
MutationQuery
,NativeQuery<T>
,NativeQueryImplementor<R>
,ProcedureCall
,ProcedureCallImplementor<R>
,Query<R>
,QueryImplementor<R>
,SelectionQuery<R>
,SqmQuery
,SqmQueryImplementor<R>
,SqmSelectionQuery<R>
,SqmSelectionQueryImplementor<R>
- All Known Implementing Classes:
AbstractCommonQueryContract
,AbstractQuery
,AbstractSelectionQuery
,DelegatingSqmSelectionQueryImplementor
,NativeQueryImpl
,ProcedureCallImpl
,QuerySqmImpl
,SqmSelectionQueryImpl
Queries may have parameters, either ordinal or named, and the various
setParameter()
operations of this interface allow an argument to be
bound to a parameter. It's not usually necessary to explicitly specify the type
of an argument, but in rare cases where this is needed, TypedParameterValue
may be used.
The operation setFlushMode(FlushModeType)
allows a temporary flush
mode to be specified, which is in effect only during the execution of this query.
Setting the flush mode at the query level does not affect
the flush mode of other operations performed via the parent session. This operation is usually used as follows:
query.setFlushMode(COMMIT).getResultList()
The call to setFlushMode(COMMIT)
disables the usual automatic flush
operation that occurs before query execution.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGet the comment that has been set for this query, if any.The JPAFlushModeType
in effect for this query.TheFlushMode
in effect for this query.Obtain the query timeout in seconds.setComment
(String comment) Set a comment for this query.setFlushMode
(FlushModeType flushMode) Set theFlushMode
in to use for this query.setHibernateFlushMode
(FlushMode flushMode) Set the currentFlushMode
in effect for this query.Set a hint.setParameter
(int parameter, Object value) Bind the given argument to an ordinal query parameter.setParameter
(int parameter, Instant value, TemporalType temporalType) Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
.setParameter
(int parameter, Calendar value, TemporalType temporalType) setParameter
(int parameter, Date value, TemporalType temporalType) setParameter
(int parameter, P value, Class<P> type) Bind the given argument to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.setParameter
(int parameter, P value, BindableType<P> type) Bind the given argument to an ordinal query parameter using the givenBindableType
.setParameter
(Parameter<Calendar> param, Calendar value, TemporalType temporalType) setParameter
(Parameter<Date> param, Date value, TemporalType temporalType) setParameter
(Parameter<T> param, T value) setParameter
(String parameter, Object value) Bind the given argument to a named query parameter.setParameter
(String parameter, Instant value, TemporalType temporalType) Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
.setParameter
(String parameter, Calendar value, TemporalType temporalType) setParameter
(String parameter, Date value, TemporalType temporalType) setParameter
(String parameter, P value, Class<P> type) Bind the given argument to a named query parameter using the givenClass
reference to attempt to infer theBindableType
.setParameter
(String parameter, P value, BindableType<P> type) Bind the given argument to a named query parameter using the givenBindableType
.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.setParameter
(QueryParameter<P> parameter, P val, BindableType<P> type) Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.setParameter
(QueryParameter<T> parameter, T value) Bind an argument to the query parameter represented by the givenQueryParameter
.setParameterList
(int parameter, Object[] values) Bind multiple arguments to an ordinal query parameter.setParameterList
(int parameter, Collection values) Bind multiple arguments to an ordinal query parameter.setParameterList
(int parameter, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.setParameterList
(int parameter, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to an ordinal query parameter using the givenBindableType
.setParameterList
(int parameter, P[] values, Class<P> javaType) Bind multiple arguments to an ordinal query parameter using the givenClass
reference to attempt to infer theBindableType
.setParameterList
(int parameter, P[] values, BindableType<P> type) Bind multiple arguments to an ordinal query parameter using the givenBindableType
.setParameterList
(String parameter, Object[] values) Bind multiple arguments to a named query parameter.setParameterList
(String parameter, Collection values) Bind multiple arguments to a named query parameter.setParameterList
(String parameter, 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 tosetParameterList(String, Collection)
.setParameterList
(String parameter, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to a named query parameter using the givenBindableType
.setParameterList
(String parameter, 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.setParameterList
(String parameter, P[] values, BindableType<P> type) Bind multiple arguments to a named query parameter using the givenBindableType
.setParameterList
(QueryParameter<P> parameter, Collection<? extends P> values) Bind multiple arguments to the query parameter represented by the givenQueryParameter
.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.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
.setParameterList
(QueryParameter<P> parameter, P[] values) Bind multiple arguments to the query parameter represented by the givenQueryParameter
.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.setParameterList
(QueryParameter<P> parameter, P[] values, BindableType<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the given theBindableType
.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 givenMap
to named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.setTimeout
(int timeout) Set the query timeout in seconds.
-
Method Details
-
getFlushMode
FlushModeType getFlushMode()The JPAFlushModeType
in effect for this query. By default, the query inherits theFlushMode
of theSession
from which it originates. -
setFlushMode
Set theFlushMode
in to use for this query.- See Also:
- Implementation Note:
- Setting to
null
ultimately indicates to use the FlushMode of the Session. UsesetHibernateFlushMode(org.hibernate.FlushMode)
passingFlushMode.MANUAL
instead to indicate that no automatic flushing should occur
-
getHibernateFlushMode
FlushMode getHibernateFlushMode()TheFlushMode
in effect for this query. By default, the query inherits theFlushMode
of theSession
from which it originates.- See Also:
-
setHibernateFlushMode
Set the currentFlushMode
in effect for this query.- See Also:
- Implementation Note:
- Setting to
null
ultimately indicates to use theFlushMode
of the Session. UseFlushMode.MANUAL
instead to indicate that no automatic flushing should occur.
-
getTimeout
Integer getTimeout()Obtain the query timeout in seconds.This value is eventually passed along to the JDBC statement via
Statement.setQueryTimeout(int)
.A value of zero indicates no timeout.
-
setTimeout
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.
- Parameters:
timeout
- the timeout in seconds- Returns:
this
, for method chaining- See Also:
-
getComment
String getComment()Get the comment that has been set for this query, if any. -
setComment
Set a comment for this query.- See Also:
-
setHint
Set a hint. The hints understood by Hibernate are enumerated byAvailableHints
.- See Also:
-
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 which accepts a "type".
-
setParameter
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 tosetParameter(String, Object)
. -
setParameter
Bind the given argument to a named query parameter using the givenBindableType
. -
setParameter
Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
. -
setParameter
-
setParameter
-
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".
-
setParameter
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 tosetParameter(int, Object)
.- See Also:
-
setParameter
Bind the given argument to an ordinal query parameter using the givenBindableType
. -
setParameter
Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
. -
setParameter
-
setParameter
-
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".
- Parameters:
parameter
- the query parameter mementovalue
- the argument, which might be null- Returns:
this
, for method chaining- See Also:
-
setParameter
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 tosetParameter(QueryParameter, Object)
.- 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:
-
setParameter
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.- 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
- See Also:
-
setParameter
CommonQueryContract setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) -
setParameter
-
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.
- 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> CommonQueryContract setParameterList(String parameter, 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 tosetParameterList(String, Collection)
.- 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> CommonQueryContract setParameterList(String parameter, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to a named query parameter using the givenBindableType
.- 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
- 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 theBindableType
to use. If unable to determine an appropriateBindableType
,setParameterList(String, Collection)
is used- 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 givenBindableType
.- 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
- 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
<P> CommonQueryContract setParameterList(int parameter, Collection<? extends P> values, Class<P> javaType) 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 tosetParameterList(String, Collection)
.- 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> CommonQueryContract setParameterList(int parameter, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to an ordinal query parameter using the givenBindableType
.- 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
- 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 givenClass
reference to attempt to infer theBindableType
. If unable to infer an appropriateBindableType
, fall back tosetParameterList(String, Collection)
.- 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 givenBindableType
.- 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
<P> CommonQueryContract setParameterList(QueryParameter<P> parameter, Collection<? extends P> values) 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.
- Parameters:
parameter
- the parameter mementovalues
- a collection of arguments- Returns:
this
, for method chaining
-
setParameterList
<P> CommonQueryContract 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. If unable to infer an appropriateBindableType
, fall back to usingsetParameterList(String, Collection)
.- 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> CommonQueryContract 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
.- 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.- Parameters:
parameter
- the parameter mementovalues
- a collection of arguments- Returns:
this
, for method chaining
-
setParameterList
<P> CommonQueryContract 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. If unable to infer an appropriateBindableType
, fall back to usingsetParameterList(String, Collection)
.- 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> CommonQueryContract setParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter
, using the given theBindableType
.- 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.- Parameters:
bean
- any JavaBean or POJO- Returns:
this
, for method chaining
-
setProperties
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.- Parameters:
bean
- aMap
of names to arguments- Returns:
this
, for method chaining
-