public interface Query<R> extends TypedQuery<R>, Query<R>, CommonQueryContract
Represents an HQL/JPQL query or a compiled Criteria query. Also acts as the Hibernate
extension to the JPA Query/TypedQuery contract
<p/>
NOTE: Query is deprecated, and slated for removal in 6.0.
For the time being we leave all methods defined on Query
rather than here because it was previously the public API so we want to leave that
unchanged in 5.x. For 6.0 we will move those methods here and then delete that class.
| Modifier and Type | Method and Description |
|---|---|
Query<R> |
addQueryHint(String hint)
Add a DB query hint to the SQL.
|
CacheMode |
getCacheMode()
Obtain the CacheMode in effect for this query.
|
String |
getCacheRegion()
Obtain the name of the second level query cache region in which query results will be stored (if they are
cached, see the discussion on
Query.isCacheable() for more information). |
String |
getComment()
Obtain the comment currently associated with this query.
|
Integer |
getFetchSize()
Obtain the JDBC fetch size hint in effect for this query.
|
FlushMode |
getHibernateFlushMode()
Obtain the FlushMode in effect for this query.
|
LockOptions |
getLockOptions()
Obtains the LockOptions in effect for this query.
|
ParameterMetadata |
getParameterMetadata()
Access to information about query parameters.
|
QueryProducer |
getProducer()
Get the QueryProducer this Query originates from.
|
RowSelection |
getQueryOptions()
"QueryOptions" is a better name, I think, than "RowSelection" → 6.0
|
String |
getQueryString()
Get the query string.
|
default List<R> |
getResultList() |
default Stream<R> |
getResultStream()
|
default R |
getSingleResult() |
List<R> |
list()
Return the query results as a <tt>List</tt>.
|
ScrollableResults |
scroll()
Return the query results as <tt>ScrollableResults</tt>.
|
ScrollableResults |
scroll(ScrollMode scrollMode)
Return the query results as ScrollableResults.
|
default Query<R> |
setBigDecimal(int position,
BigDecimal val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBigDecimal(String name,
BigDecimal val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setBigInteger(int position,
BigInteger val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBigInteger(String name,
BigInteger val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setBinary(int position,
byte[] val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBinary(String name,
byte[] val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setBoolean(int position,
boolean val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBoolean(String name,
boolean val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setByte(int position,
byte val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setByte(String name,
byte val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setCacheable(boolean cacheable)
Enable/disable second level query (result) caching for this query.
|
Query<R> |
setCacheMode(CacheMode cacheMode)
(Re)set the current CacheMode in effect for this query.
|
Query<R> |
setCacheRegion(String cacheRegion)
Set the name of the cache region where query results should be cached (if cached at all).
|
default Query<R> |
setCalendar(int position,
Calendar val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setCalendar(String name,
Calendar value)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setCalendarDate(int position,
Calendar val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setCalendarDate(String name,
Calendar value)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setCharacter(int position,
char val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setCharacter(String name,
char val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setComment(String comment)
Set the comment for this query.
|
default Query<R> |
setDate(int position,
Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setDate(String name,
Date val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setDouble(int position,
double val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setDouble(String name,
double val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setEntity(int position,
Object val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setEntity(String name,
Object val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.
|
Query<R> |
setFirstResult(int startPosition) |
default Query<R> |
setFloat(int position,
float val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setFloat(String name,
float val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setFlushMode(FlushMode flushMode)
Deprecated.
(since 5.2) use
setHibernateFlushMode(org.hibernate.FlushMode) instead |
Query<R> |
setFlushMode(FlushModeType flushMode) |
Query<R> |
setHibernateFlushMode(FlushMode flushMode)
(Re)set the current FlushMode in effect for this query.
|
Query<R> |
setHint(String hintName,
Object value) |
default Query<R> |
setInteger(int position,
int val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setInteger(String name,
int val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setLocale(int position,
Locale val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setLocale(String name,
Locale val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setLockMode(LockModeType lockMode) |
Query<R> |
setLockMode(String alias,
LockMode lockMode)
Set the LockMode to use for specific alias (as defined in the query’s <tt>FROM</tt> clause).
|
Query<R> |
setLockOptions(LockOptions lockOptions)
Set the lock options for the query.
|
default Query<R> |
setLong(int position,
long val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setLong(String name,
long val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setMaxResults(int maxResult) |
Query<R> |
setParameter(int position,
Calendar value,
TemporalType temporalType) |
Query<R> |
setParameter(int position,
Date value,
TemporalType temporalType) |
Query<R> |
setParameter(int position,
Instant value,
TemporalType temporalType) |
Query<R> |
setParameter(int position,
LocalDateTime value,
TemporalType temporalType) |
Query<R> |
setParameter(int position,
Object value)
Bind a positional query parameter using its inferred Type.
|
Query<R> |
setParameter(int position,
Object val,
Type type)
Bind a value to a JDBC-style query parameter.
|
Query<R> |
setParameter(int position,
OffsetDateTime value,
TemporalType temporalType) |
<P> Query<R> |
setParameter(int position,
P val,
TemporalType temporalType)
Bind a positional query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameter(int position,
ZonedDateTime value,
TemporalType temporalType) |
Query<R> |
setParameter(Parameter<Calendar> param,
Calendar value,
TemporalType temporalType) |
Query<R> |
setParameter(Parameter<Date> param,
Date value,
TemporalType temporalType) |
Query<R> |
setParameter(Parameter<Instant> param,
Instant value,
TemporalType temporalType) |
Query<R> |
setParameter(Parameter<LocalDateTime> param,
LocalDateTime value,
TemporalType temporalType) |
Query<R> |
setParameter(Parameter<OffsetDateTime> param,
OffsetDateTime value,
TemporalType temporalType) |
<T> Query<R> |
setParameter(Parameter<T> param,
T value) |
Query<R> |
setParameter(Parameter<ZonedDateTime> param,
ZonedDateTime value,
TemporalType temporalType) |
<P> Query<R> |
setParameter(QueryParameter<P> parameter,
P val,
TemporalType temporalType)
Bind a query parameter as some form of date/time using the indicated
temporal-type.
|
<P> Query<R> |
setParameter(QueryParameter<P> parameter,
P val,
Type type)
Bind a query parameter using the supplied Type
|
<T> Query<R> |
setParameter(QueryParameter<T> parameter,
T val)
Bind a query parameter using its inferred Type.
|
Query<R> |
setParameter(String name,
Calendar value,
TemporalType temporalType) |
Query<R> |
setParameter(String name,
Date value,
TemporalType temporalType) |
Query<R> |
setParameter(String name,
Instant value,
TemporalType temporalType) |
Query<R> |
setParameter(String name,
LocalDateTime value,
TemporalType temporalType) |
Query<R> |
setParameter(String name,
Object value)
Bind a named query parameter using its inferred Type.
|
Query<R> |
setParameter(String name,
Object val,
Type type)
Bind a named query parameter using the supplied Type
|
Query<R> |
setParameter(String name,
OffsetDateTime value,
TemporalType temporalType) |
<P> Query<R> |
setParameter(String name,
P val,
TemporalType temporalType)
Bind a named query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameter(String name,
ZonedDateTime value,
TemporalType temporalType) |
<P> Query<R> |
setParameterList(QueryParameter<P> parameter,
Collection<P> values)
Bind multiple values to a query parameter using its inferred Type.
|
Query<R> |
setParameterList(String name,
Collection values)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Collection values,
Type type)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Object[] values)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Object[] values,
Type type)
Bind multiple values to a named query parameter.
|
default Query<R> |
setParameters(Object[] values,
Type[] types)
Deprecated.
(since 5.2) Bind values individually
|
Query<R> |
setProperties(Map bean)
Bind the values of the given Map for each named parameters of the query,
matching key names with parameter names and mapping value types to
Hibernate types using heuristics.
|
Query<R> |
setProperties(Object bean)
Bind the property values of the given bean to named parameters of the query,
matching property names with parameter names and mapping property types to
Hibernate types using heuristics.
|
Query<R> |
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies
loaded by this Query.
|
Query<R> |
setResultTransformer(ResultTransformer transformer)
Deprecated.
(since 5.2)
|
default Query<R> |
setSerializable(int position,
Serializable val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setSerializable(String name,
Serializable val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setShort(int position,
short val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setShort(String name,
short val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setString(int position,
String val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setString(String name,
String val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setText(int position,
String val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setText(String name,
String val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setTime(int position,
Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setTime(String name,
Date val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setTimeout(int timeout)
Set the query timeout <b>in seconds</b>.
|
default Query<R> |
setTimestamp(int position,
Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setTimestamp(String name,
Date value)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Stream<R> |
stream()
Retrieve a Stream over the query results.
|
R |
uniqueResult()
Convenience method to return a single instance that matches
the query, or
null if the query returns no results. |
Optional<R> |
uniqueResultOptional() |
determineProperBooleanType, determineProperBooleanType, getFlushMode, getNamedParameters, getReturnAliases, getReturnTypes, getTimeout, isCacheable, isReadOnly, iterate, setParameterList, setParameterList, setParameterList, setParameterListexecuteUpdate, getFirstResult, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrapQueryProducer getProducer()
Get the QueryProducer this Query originates from.
RowSelection getQueryOptions()
"QueryOptions" is a better name, I think, than "RowSelection" → 6.0
Stream<R> stream()
Retrieve a Stream over the query results. <p/> In the initial implementation (5.2) this returns a simple sequential Stream. The plan is to return a a smarter stream in 6.x leveraging the SQM model.
<p>
You should call BaseStream.close() after processing the stream
so that the underlying resources are deallocated right away.
Query<R> setParameter(Parameter<Instant> param, Instant value, TemporalType temporalType)
Query<R> setParameter(Parameter<LocalDateTime> param, LocalDateTime value, TemporalType temporalType)
Query<R> setParameter(Parameter<ZonedDateTime> param, ZonedDateTime value, TemporalType temporalType)
Query<R> setParameter(Parameter<OffsetDateTime> param, OffsetDateTime value, TemporalType temporalType)
Query<R> setParameter(String name, Instant value, TemporalType temporalType)
Query<R> setParameter(String name, LocalDateTime value, TemporalType temporalType)
Query<R> setParameter(String name, ZonedDateTime value, TemporalType temporalType)
Query<R> setParameter(String name, OffsetDateTime value, TemporalType temporalType)
Query<R> setParameter(int position, Instant value, TemporalType temporalType)
Query<R> setParameter(int position, LocalDateTime value, TemporalType temporalType)
Query<R> setParameter(int position, ZonedDateTime value, TemporalType temporalType)
Query<R> setParameter(int position, OffsetDateTime value, TemporalType temporalType)
ScrollableResults scroll()
QueryReturn the query results as <tt>ScrollableResults</tt>. The scrollability of the returned results depends upon JDBC driver support for scrollable <tt>ResultSet</tt>s.
<p>
You should call ScrollableResults.close() after processing the <tt>ScrollableResults</tt>
so that the underlying resources are deallocated right away.
ScrollableResultsScrollableResults scroll(ScrollMode scrollMode)
QueryReturn the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.
<p>
You should call ScrollableResults.close() after processing the <tt>ScrollableResults</tt>
so that the underlying resources are deallocated right away.
scrollMode - The scroll modeScrollableResults,
ScrollModeList<R> list()
QueryReturn the query results as a <tt>List</tt>. If the query contains multiple results per row, the results are returned in an instance of <tt>Object[]</tt>.
default List<R> getResultList()
getResultList in interface QuerygetResultList in interface TypedQuery<R>R uniqueResult()
QueryConvenience method to return a single instance that matches
the query, or null if the query returns no results.
default R getSingleResult()
getSingleResult in interface QuerygetSingleResult in interface TypedQuery<R>FlushMode getHibernateFlushMode()
QueryObtain the FlushMode in effect for this query. By default, the query inherits the FlushMode of the Session from which it originates.
getHibernateFlushMode in interface BasicQueryContract<CommonQueryContract>FlushModeCacheMode getCacheMode()
QueryObtain the CacheMode in effect for this query. By default, the query inherits the CacheMode of the Session from which is originates.
|
Note
|
The CacheMode here only effects reading/writing of the query cache, not the entity/collection caches. |
getCacheMode in interface BasicQueryContract<CommonQueryContract>Session.getCacheMode(),
CacheModeString getCacheRegion()
QueryObtain the name of the second level query cache region in which query results will be stored (if they are
cached, see the discussion on Query.isCacheable() for more information). null indicates that the
default region should be used.
getCacheRegion in interface BasicQueryContract<CommonQueryContract>null indicates
the default region.Integer getFetchSize()
QueryObtain the JDBC fetch size hint in effect for this query. This value is eventually passed along to the JDBC
query via Statement.setFetchSize(int). As defined b y JDBC, this value is a hint to the
driver to indicate how many rows to fetch from the database when more rows are needed.
NOTE : JDBC expressly defines this value as a hint. It may or may not have any effect on the actual query execution and ResultSet processing depending on the driver.
getFetchSize in interface BasicQueryContract<CommonQueryContract>Statement.getFetchSize(),
Statement.setFetchSize(int)LockOptions getLockOptions()
QueryObtains the LockOptions in effect for this query.
LockOptionsString getComment()
QueryObtain the comment currently associated with this query. Provided SQL commenting is enabled
(generally by enabling the hibernate.use_sql_comments config setting), this comment will also be added
to the SQL query sent to the database. Often useful for identifying the source of troublesome queries on the
database side.
String getQueryString()
QueryGet the query string.
ParameterMetadata getParameterMetadata()
QueryAccess to information about query parameters.
Query<R> setMaxResults(int maxResult)
setMaxResults in interface QuerysetMaxResults in interface TypedQuery<R>Query<R> setFirstResult(int startPosition)
setFirstResult in interface QuerysetFirstResult in interface TypedQuery<R>Query<R> setHint(String hintName, Object value)
setHint in interface QuerysetHint in interface TypedQuery<R><T> Query<R> setParameter(Parameter<T> param, T value)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(String name, Object value)
QueryBind a named query parameter using its inferred Type. If the parameter is
defined in such a way that the Type cannot be inferred from its usage context then
use of this form of binding is not allowed, and Query.setParameter(String, Object, Type)
should be used instead
setParameter in interface QuerysetParameter in interface TypedQuery<R>name - the parameter namevalue - the (possibly-null) parameter valuethis, for method chainingQuery<R> setParameter(String name, Object val, Type type)
QueryBind a named query parameter using the supplied Type
name - the name of the parameterval - the possibly-null parameter valuetype - the Hibernate typethis, for method chainingQuery<R> setParameter(String name, Calendar value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(String name, Date value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(int position, Object value)
QueryBind a positional query parameter using its inferred Type. If the parameter is
defined in such a way that the Type cannot be inferred from its usage context then
use of this form of binding is not allowed, and Query.setParameter(int, Object, Type)
should be used instead
setParameter in interface QuerysetParameter in interface TypedQuery<R>position - the position of the parameter in the query
string, numbered from <tt>0</tt>.value - the possibly-null parameter valuethis, for method chainingQuery<R> setParameter(int position, Calendar value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R>Query<R> setParameter(int position, Date value, TemporalType temporalType)
setParameter in interface QuerysetParameter in interface TypedQuery<R><T> Query<R> setParameter(QueryParameter<T> parameter, T val)
QueryBind a query parameter using its inferred Type. If the parameter is
defined in such a way that the Type cannot be inferred from its usage context then
use of this form of binding is not allowed, and Query.setParameter(QueryParameter, Object, Type)
should be used instead
parameter - The query parameter mementoval - the possibly-null parameter valuethis, for method chaining<P> Query<R> setParameter(int position, P val, TemporalType temporalType)
QueryBind a positional query parameter as some form of date/time using the indicated temporal-type.
position - the position of the parameter in the query
string, numbered from <tt>0</tt>.val - the possibly-null parameter valuetemporalType - the temporal-type to use in binding the date/timethis, for method chaining<P> Query<R> setParameter(QueryParameter<P> parameter, P val, Type type)
QueryBind a query parameter using the supplied Type
parameter - The query parameter mementoval - the possibly-null parameter valuetype - the Hibernate typethis, for method chainingQuery<R> setParameter(int position, Object val, Type type)
QueryBind a value to a JDBC-style query parameter.
position - the position of the parameter in the query
string, numbered from <tt>0</tt>.val - the possibly-null parameter valuetype - the Hibernate typethis, for method chaining<P> Query<R> setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType)
QueryBind a query parameter as some form of date/time using the indicated temporal-type.
parameter - The query parameter mementoval - the possibly-null parameter valuetemporalType - the temporal-type to use in binding the date/timethis, for method chaining<P> Query<R> setParameter(String name, P val, TemporalType temporalType)
QueryBind a named query parameter as some form of date/time using the indicated temporal-type.
name - the parameter nameval - the possibly-null parameter valuetemporalType - the temporal-type to use in binding the date/timethis, for method chainingQuery<R> setFlushMode(FlushModeType flushMode)
setFlushMode in interface QuerysetFlushMode in interface TypedQuery<R>Query<R> setLockMode(LockModeType lockMode)
setLockMode in interface QuerysetLockMode in interface TypedQuery<R>Query<R> setReadOnly(boolean readOnly)
QuerySet the read-only/modifiable mode for entities and proxies loaded by this Query. This setting overrides the default setting for the persistence context.
setReadOnly in interface BasicQueryContract<CommonQueryContract>readOnly - true indicates that entities and proxies loaded by the query
are to be put in read-only mode; false indicates that entities and proxies
loaded by the query will be put in modifiable modethis, for method chainingPersistenceContext.isDefaultReadOnly(),
PersistenceContext.setDefaultReadOnly(boolean),
Session.setDefaultReadOnly(boolean)Query<R> setHibernateFlushMode(FlushMode flushMode)
Query(Re)set the current FlushMode in effect for this query.
setHibernateFlushMode in interface BasicQueryContract<CommonQueryContract>flushMode - The new FlushMode to use.this, for method chainingQuery.getHibernateFlushMode()Query<R> setCacheMode(CacheMode cacheMode)
Query(Re)set the current CacheMode in effect for this query.
setCacheMode in interface BasicQueryContract<CommonQueryContract>cacheMode - The new CacheMode to use.this, for method chainingQuery.getCacheMode()Query<R> setCacheable(boolean cacheable)
QueryEnable/disable second level query (result) caching for this query.
setCacheable in interface BasicQueryContract<CommonQueryContract>cacheable - Should the query results be cacheable?this, for method chainingQuery.isCacheable()Query<R> setCacheRegion(String cacheRegion)
QuerySet the name of the cache region where query results should be cached (if cached at all).
setCacheRegion in interface BasicQueryContract<CommonQueryContract>cacheRegion - the name of a query cache region, or null to indicate that the default region
should be used.this, for method chainingQuery.getCacheRegion()Query<R> setTimeout(int timeout)
QuerySet the query timeout <b>in seconds</b>.
NOTE it is important to understand that any value set here is eventually passed directly through to the JDBC Statement which expressly disallows negative values. So negative values should be avoided as a general rule.
setTimeout in interface BasicQueryContract<CommonQueryContract>timeout - the timeout <b>in seconds</b>this, for method chainingQuery.getTimeout()Query<R> setFetchSize(int fetchSize)
QuerySets a JDBC fetch size hint for the query.
setFetchSize in interface BasicQueryContract<CommonQueryContract>fetchSize - the fetch size hintthis, for method chainingQuery.getFetchSize()Query<R> setLockOptions(LockOptions lockOptions)
QuerySet the lock options for the query. Specifically only the following are taken into consideration:<ol>
<li>LockOptions.getLockMode()</li>
<li>LockOptions.getScope()</li>
<li>LockOptions.getTimeOut()</li>
</ol>
For alias-specific locking, use Query.setLockMode(String, LockMode).
lockOptions - The lock options to apply to the query.this, for method chainingQuery.getLockOptions()Query<R> setLockMode(String alias, LockMode lockMode)
QuerySet the LockMode to use for specific alias (as defined in the query’s <tt>FROM</tt> clause).
The alias-specific lock modes specified here are added to the query’s internal
LockOptions.
The effect of these alias-specific LockModes is somewhat dependent on the driver/database in use. Generally
speaking, for maximum portability, this method should only be used to mark that the rows corresponding to
the given alias should be included in pessimistic locking (LockMode.PESSIMISTIC_WRITE).
alias - a query alias, or "this" for a collection filterlockMode - The lock mode to apply.this, for method chainingQuery.getLockOptions()Query<R> setComment(String comment)
QuerySet the comment for this query.
comment - The human-readable commentthis, for method chainingQuery.getComment()Query<R> addQueryHint(String hint)
QueryAdd a DB query hint to the SQL. These differ from JPA’s QueryHint, which is specific
to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the
vendor-specific hints, such as Oracle’s optimizers. Multiple query hints are supported; the Dialect will
determine concatenation and placement.
hint - The database specific query hint to add.<P> Query<R> setParameterList(QueryParameter<P> parameter, Collection<P> values)
QueryBind multiple values to a query parameter using its inferred Type. The Hibernate type of the parameter values is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
parameter - the parameter mementovalues - a collection of values to listthis, for method chainingQuery<R> setParameterList(String name, Collection values)
QueryBind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
name - the name of the parametervalues - a collection of values to listthis, for method chainingQuery<R> setParameterList(String name, Collection values, Type type)
QueryBind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
name - the name of the parametervalues - a collection of values to listtype - the Hibernate type of the valuesthis, for method chainingQuery<R> setParameterList(String name, Object[] values, Type type)
QueryBind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
name - the name of the parametervalues - a collection of values to listtype - the Hibernate type of the valuesthis, for method chainingQuery<R> setParameterList(String name, Object[] values)
QueryBind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
name - the name of the parametervalues - a collection of values to listthis, for method chainingQuery<R> setProperties(Object bean)
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.
bean - any JavaBean or POJOthis, for method chainingQuery<R> setProperties(Map bean)
QueryBind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.
bean - a java.util.Mapthis, for method chaining@Deprecated default Query<R> setFlushMode(FlushMode flushMode)
setHibernateFlushMode(org.hibernate.FlushMode) instead(Re)set the current FlushMode in effect for this query.
setFlushMode in interface BasicQueryContract<CommonQueryContract>flushMode - The new FlushMode to use.this, for method chaininggetHibernateFlushMode()@Deprecated default Query<R> setString(int position, String val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional String-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setCharacter(int position, char val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional char-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setBoolean(int position, boolean val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional boolean-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setByte(int position, byte val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional byte-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setShort(int position, short val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional short-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setInteger(int position, int val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional int-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setLong(int position, long val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional long-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setFloat(int position, float val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional float-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setDouble(int position, double val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional double-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setBinary(int position, byte[] val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional binary-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setText(int position, String val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional String-valued parameter using streaming.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setSerializable(int position, Serializable val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional binary-valued parameter using serialization.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setLocale(int position, Locale val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Locale-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setBigDecimal(int position, BigDecimal val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional BigDecimal-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setBigInteger(int position, BigInteger val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional BigDecimal-valued parameter.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setDate(int position, Date val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Date-valued parameter using just the Date portion.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setTime(int position, Date val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Date-valued parameter using just the Time portion.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setTimestamp(int position, Date val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Date-valued parameter using the full Timestamp.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setCalendar(int position, Calendar val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Calendar-valued parameter using the full Timestamp portion.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setCalendarDate(int position, Calendar val)
setParameter(int, Object) or setParameter(int, Object, Type)
insteadBind a positional Calendar-valued parameter using just the Date portion.
position - The parameter positionval - The bind valuethis, for method chaining@Deprecated default Query<R> setString(String name, String val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named String-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setCharacter(String name, char val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named char-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setBoolean(String name, boolean val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named boolean-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setByte(String name, byte val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named byte-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setShort(String name, short val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named short-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setInteger(String name, int val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named int-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setLong(String name, long val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named long-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setFloat(String name, float val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named float-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setDouble(String name, double val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named double-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setBinary(String name, byte[] val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named binary-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setText(String name, String val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named String-valued parameter using streaming.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setSerializable(String name, Serializable val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named binary-valued parameter using serialization.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setLocale(String name, Locale val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named Locale-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setBigDecimal(String name, BigDecimal val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named BigDecimal-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setBigInteger(String name, BigInteger val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named BigInteger-valued parameter.
name - The parameter nameval - The bind valuethis, for method chaining@Deprecated default Query<R> setDate(String name, Date val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind the val (time is truncated) of a given Date object to a named query parameter.
name - The name of the parameterval - The val objectthis, for method chaining@Deprecated default Query<R> setTime(String name, Date val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind the time (val is truncated) of a given Date object to a named query parameter.
name - The name of the parameterval - The val objectthis, for method chaining@Deprecated default Query<R> setTimestamp(String name, Date value)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind the value and the time of a given Date object to a named query parameter.
name - The name of the parametervalue - The value objectthis, for method chaining@Deprecated default Query<R> setCalendar(String name, Calendar value)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named Calendar-valued parameter using the full Timestamp.
name - The parameter namevalue - The bind valuethis, for method chaining@Deprecated default Query<R> setCalendarDate(String name, Calendar value)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind a named Calendar-valued parameter using just the Date portion.
name - The parameter namevalue - The bind valuethis, for method chaining@Deprecated Query<R> setEntity(int position, Object val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind an instance of a mapped persistent class to a JDBC-style query parameter.
Use setParameter(int, Object) for null values.
position - the position of the parameter in the query
string, numbered from <tt>0</tt>.val - a non-null instance of a persistent classthis, for method chaining@Deprecated Query<R> setEntity(String name, Object val)
setParameter(String, Object) or setParameter(String, Object, Type)
insteadBind an instance of a mapped persistent class to a named query parameter. Use
setParameter(String, Object) for null values.
name - the name of the parameterval - a non-null instance of a persistent classthis, for method chaining@Deprecated Query<R> setResultTransformer(ResultTransformer transformer)
Set a strategy for handling the query results. This can be used to change "shape" of the query result.
transformer - The transformer to apply@Deprecated default Query<R> setParameters(Object[] values, Type[] types)
Bind values and types to positional parameters. Allows binding more than one at a time; no real performance impact.
The number of elements in each array should match. That is, element number-0 in types array corresponds to element-0 in the values array, etc,
types - The typesvalues - The valuesthis, for method chainingdefault Stream<R> getResultStream()
JPA 2.2 defines the getResultStream method so to get a Stream from the JDBC ResultSet.
Hibernate 5.2 already defines the stream() method, so getResultStream can delegate to it.
getResultStream in interface QuerygetResultStream in interface TypedQuery<R>Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.