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
public interface CommonQueryContract
Defines the aspects of query execution and parameter binding that apply to all forms of querying: HQL/JPQL queries, native SQL queries, criteria queries, and stored procedure calls.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:
Query
,SelectionQuery
,MutationQuery
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getComment()
Get the comment that has been set for this query, if any.FlushModeType
getFlushMode()
The JPAFlushModeType
in effect for this query.FlushMode
getHibernateFlushMode()
TheFlushMode
in effect for this query.Integer
getTimeout()
Obtain the query timeout in seconds.CommonQueryContract
setComment(String comment)
Set a comment for this query.CommonQueryContract
setFlushMode(FlushModeType flushMode)
Set theFlushMode
in to use for this query.CommonQueryContract
setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
in effect for this query.CommonQueryContract
setHint(String hintName, Object value)
Set a hint.CommonQueryContract
setParameter(int parameter, Object value)
Bind the given argument to an ordinal query parameter.CommonQueryContract
setParameter(int parameter, Instant value, TemporalType temporalType)
Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
.CommonQueryContract
setParameter(int parameter, Calendar value, TemporalType temporalType)
CommonQueryContract
setParameter(int parameter, Date value, TemporalType temporalType)
<P> CommonQueryContract
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
.<P> CommonQueryContract
setParameter(int parameter, P value, BindableType<P> type)
Bind the given argument to an ordinal query parameter using the givenBindableType
.CommonQueryContract
setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
CommonQueryContract
setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
<T> CommonQueryContract
setParameter(Parameter<T> param, T value)
CommonQueryContract
setParameter(String parameter, Object value)
Bind the given argument to a named query parameter.CommonQueryContract
setParameter(String parameter, Instant value, TemporalType temporalType)
Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
.CommonQueryContract
setParameter(String parameter, Calendar value, TemporalType temporalType)
CommonQueryContract
setParameter(String parameter, Date value, TemporalType temporalType)
<P> CommonQueryContract
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
.<P> CommonQueryContract
setParameter(String parameter, P value, BindableType<P> type)
Bind the given argument to a named query parameter using the givenBindableType
.<P> CommonQueryContract
setParameter(QueryParameter<P> parameter, P value, Class<P> type)
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenClass
reference to attempt to infer theBindableType
to use.<P> CommonQueryContract
setParameter(QueryParameter<P> parameter, P val, BindableType<P> type)
Bind an argument to the query parameter represented by the givenQueryParameter
, using the givenBindableType
.<T> CommonQueryContract
setParameter(QueryParameter<T> parameter, T value)
Bind an argument to the query parameter represented by the givenQueryParameter
.CommonQueryContract
setParameterList(int parameter, Object[] values)
Bind multiple arguments to an ordinal query parameter.CommonQueryContract
setParameterList(int parameter, Collection values)
Bind multiple arguments to an ordinal query parameter.<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
.<P> CommonQueryContract
setParameterList(int parameter, Collection<? extends P> values, BindableType<P> type)
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.<P> CommonQueryContract
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
.<P> CommonQueryContract
setParameterList(int parameter, P[] values, BindableType<P> type)
Bind multiple arguments to an ordinal query parameter using the givenBindableType
.CommonQueryContract
setParameterList(String parameter, Object[] values)
Bind multiple arguments to a named query parameter.CommonQueryContract
setParameterList(String parameter, Collection values)
Bind multiple arguments to a named query parameter.<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)
.<P> CommonQueryContract
setParameterList(String parameter, Collection<? extends P> values, BindableType<P> type)
Bind multiple arguments to a named query parameter using the givenBindableType
.<P> CommonQueryContract
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.<P> CommonQueryContract
setParameterList(String parameter, P[] values, BindableType<P> type)
Bind multiple arguments to a named query parameter using the givenBindableType
.<P> CommonQueryContract
setParameterList(QueryParameter<P> parameter, Collection<? extends P> values)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.<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.<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
.<P> CommonQueryContract
setParameterList(QueryParameter<P> parameter, P[] values)
Bind multiple arguments to the query parameter represented by the givenQueryParameter
.<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.<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
.CommonQueryContract
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.CommonQueryContract
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.CommonQueryContract
setTimeout(int timeout)
Set the query timeout in seconds.
-
-
-
Method Detail
-
getFlushMode
FlushModeType getFlushMode()
The JPAFlushModeType
in effect for this query. By default, the query inherits theFlushMode
of theSession
from which it originates.
-
setFlushMode
CommonQueryContract setFlushMode(FlushModeType flushMode)
Set theFlushMode
in to use for this query.- See Also:
getHibernateFlushMode()
,Session.getHibernateFlushMode()
- 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:
Session.getHibernateFlushMode()
-
setHibernateFlushMode
CommonQueryContract setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
in effect for this query.- See Also:
getHibernateFlushMode()
,Session.getHibernateFlushMode()
- 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
CommonQueryContract setTimeout(int timeout)
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:
getTimeout()
-
getComment
String getComment()
Get the comment that has been set for this query, if any.
-
setComment
CommonQueryContract setComment(String comment)
Set a comment for this query.- See Also:
Query.setComment(String)
-
setHint
CommonQueryContract setHint(String hintName, Object value)
Set a hint. The hints understood by Hibernate are enumerated byAvailableHints
.- See Also:
HibernateHints
,SpecHints
-
setParameter
CommonQueryContract setParameter(String parameter, Object value)
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
<P> CommonQueryContract 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
. If unable to infer an appropriateBindableType
, fall back tosetParameter(String, Object)
.
-
setParameter
<P> CommonQueryContract setParameter(String parameter, P value, BindableType<P> type)
Bind the given argument to a named query parameter using the givenBindableType
.
-
setParameter
CommonQueryContract setParameter(String parameter, Instant value, TemporalType temporalType)
Bind anInstant
to the named query parameter using just the portion indicated by the givenTemporalType
.
-
setParameter
CommonQueryContract setParameter(String parameter, Calendar value, TemporalType temporalType)
-
setParameter
CommonQueryContract setParameter(String parameter, Date value, TemporalType temporalType)
-
setParameter
CommonQueryContract setParameter(int parameter, Object value)
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
<P> CommonQueryContract 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
. If unable to infer an appropriateBindableType
, fall back tosetParameter(int, Object)
.- See Also:
setParameter(int, Object, BindableType)
-
setParameter
<P> CommonQueryContract setParameter(int parameter, P value, BindableType<P> type)
Bind the given argument to an ordinal query parameter using the givenBindableType
.
-
setParameter
CommonQueryContract setParameter(int parameter, Instant value, TemporalType temporalType)
Bind anInstant
to an ordinal query parameter using just the portion indicated by the givenTemporalType
.
-
setParameter
CommonQueryContract setParameter(int parameter, Date value, TemporalType temporalType)
-
setParameter
CommonQueryContract setParameter(int parameter, Calendar value, TemporalType temporalType)
-
setParameter
<T> CommonQueryContract setParameter(QueryParameter<T> parameter, T value)
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(QueryParameter, Object, BindableType)
-
setParameter
<P> CommonQueryContract 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. 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(QueryParameter, Object, BindableType)
-
setParameter
<P> CommonQueryContract setParameter(QueryParameter<P> parameter, P val, BindableType<P> type)
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
<T> CommonQueryContract setParameter(Parameter<T> param, T value)
- See Also:
Query.setParameter(Parameter, Object)
-
setParameter
CommonQueryContract setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
-
setParameter
CommonQueryContract setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
-
setParameterList
CommonQueryContract setParameterList(String parameter, Collection values)
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:
setParameterList(java.lang.String, java.util.Collection, BindableType)
- 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:
setParameterList(java.lang.String, java.util.Collection, BindableType)
- 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
CommonQueryContract setParameterList(String parameter, Object[] values)
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
<P> CommonQueryContract 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. If unable to determine an appropriateBindableType
,setParameterList(String, Collection)
is used- Returns:
this
, for method chaining- See Also:
setParameterList(java.lang.String, Object[], BindableType)
- 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, 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
CommonQueryContract setParameterList(int parameter, Collection values)
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:
setParameterList(int, Collection, BindableType)
- 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
CommonQueryContract setParameterList(int parameter, Object[] values)
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, 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:
setParameterList(int, Object[], BindableType)
- 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, 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
<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:
setParameterList(QueryParameter, java.util.Collection, BindableType)
- 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
<P> CommonQueryContract setParameterList(QueryParameter<P> parameter, P[] values)
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:
setParameterList(QueryParameter, Object[], BindableType)
- 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
CommonQueryContract 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.- Parameters:
bean
- any JavaBean or POJO- Returns:
this
, for method chaining
-
setProperties
CommonQueryContract 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.- Parameters:
bean
- aMap
of names to arguments- Returns:
this
, for method chaining
-
-