public interface Query<R> extends javax.persistence.TypedQuery<R>, Query<R>, CommonQueryContract
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(java.lang.String hint)
Add a DB query hint to the SQL.
|
CacheMode |
getCacheMode()
Obtain the CacheMode in effect for this query.
|
java.lang.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). |
java.lang.String |
getComment()
Obtain the comment currently associated with this query.
|
java.lang.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
|
java.lang.String |
getQueryString()
Get the query string.
|
default java.util.List<R> |
getResultList() |
default java.util.stream.Stream<R> |
getResultStream()
JPA 2.2 defines the
getResultStream method so to get a Stream from the JDBC ResultSet . |
default R |
getSingleResult() |
java.util.List<R> |
list()
Return the query results as a List.
|
ScrollableResults |
scroll()
Return the query results as ScrollableResults.
|
ScrollableResults |
scroll(ScrollMode scrollMode)
Return the query results as ScrollableResults.
|
default Query<R> |
setBigDecimal(int position,
java.math.BigDecimal val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBigDecimal(java.lang.String name,
java.math.BigDecimal val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setBigInteger(int position,
java.math.BigInteger val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setBigInteger(java.lang.String name,
java.math.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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,
java.util.Calendar val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setCalendar(java.lang.String name,
java.util.Calendar value)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setCalendarDate(int position,
java.util.Calendar val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setCalendarDate(java.lang.String name,
java.util.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(java.lang.String name,
char val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setComment(java.lang.String comment)
Set the comment for this query.
|
default Query<R> |
setDate(int position,
java.util.Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setDate(java.lang.String name,
java.util.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(java.lang.String name,
double val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setEntity(int position,
java.lang.Object val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setEntity(java.lang.String name,
java.lang.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(java.lang.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(javax.persistence.FlushModeType flushMode) |
Query<R> |
setHibernateFlushMode(FlushMode flushMode)
(Re)set the current FlushMode in effect for this query.
|
Query<R> |
setHint(java.lang.String hintName,
java.lang.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(java.lang.String name,
int val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setLocale(int position,
java.util.Locale val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setLocale(java.lang.String name,
java.util.Locale val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
Query<R> |
setLockMode(javax.persistence.LockModeType lockMode) |
Query<R> |
setLockMode(java.lang.String alias,
LockMode lockMode)
Set the LockMode to use for specific alias (as defined in the query's FROM 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(java.lang.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,
java.util.Calendar value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(int position,
java.util.Date value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(int position,
java.time.Instant value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(int position,
java.time.LocalDateTime value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(int position,
java.lang.Object value)
Bind a positional query parameter using its inferred Type.
|
Query<R> |
setParameter(int position,
java.lang.Object val,
Type type)
Bind a value to a JDBC-style query parameter.
|
Query<R> |
setParameter(int position,
java.time.OffsetDateTime value,
javax.persistence.TemporalType temporalType) |
<P> Query<R> |
setParameter(int position,
P val,
javax.persistence.TemporalType temporalType)
Bind a positional query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameter(int position,
java.time.ZonedDateTime value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(javax.persistence.Parameter<java.util.Calendar> param,
java.util.Calendar value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(javax.persistence.Parameter<java.util.Date> param,
java.util.Date value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(javax.persistence.Parameter<java.time.Instant> param,
java.time.Instant value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(javax.persistence.Parameter<java.time.LocalDateTime> param,
java.time.LocalDateTime value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(javax.persistence.Parameter<java.time.OffsetDateTime> param,
java.time.OffsetDateTime value,
javax.persistence.TemporalType temporalType) |
<T> Query<R> |
setParameter(javax.persistence.Parameter<T> param,
T value) |
Query<R> |
setParameter(javax.persistence.Parameter<java.time.ZonedDateTime> param,
java.time.ZonedDateTime value,
javax.persistence.TemporalType temporalType) |
<P> Query<R> |
setParameter(QueryParameter<P> parameter,
P val,
javax.persistence.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(java.lang.String name,
java.util.Calendar value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(java.lang.String name,
java.util.Date value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(java.lang.String name,
java.time.Instant value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(java.lang.String name,
java.time.LocalDateTime value,
javax.persistence.TemporalType temporalType) |
Query<R> |
setParameter(java.lang.String name,
java.lang.Object value)
Bind a named query parameter using its inferred Type.
|
Query<R> |
setParameter(java.lang.String name,
java.lang.Object val,
Type type)
Bind a named query parameter using the supplied Type
|
Query<R> |
setParameter(java.lang.String name,
java.time.OffsetDateTime value,
javax.persistence.TemporalType temporalType) |
<P> Query<R> |
setParameter(java.lang.String name,
P val,
javax.persistence.TemporalType temporalType)
Bind a named query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameter(java.lang.String name,
java.time.ZonedDateTime value,
javax.persistence.TemporalType temporalType) |
<P> Query<R> |
setParameterList(QueryParameter<P> parameter,
java.util.Collection<P> values)
Bind multiple values to a query parameter using its inferred Type.
|
Query<R> |
setParameterList(java.lang.String name,
java.util.Collection values)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(java.lang.String name,
java.util.Collection values,
Type type)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(java.lang.String name,
java.lang.Object[] values)
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(java.lang.String name,
java.lang.Object[] values,
Type type)
Bind multiple values to a named query parameter.
|
default Query<R> |
setParameters(java.lang.Object[] values,
Type[] types)
Deprecated.
(since 5.2) Bind values individually
|
Query<R> |
setProperties(java.util.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(java.lang.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,
java.io.Serializable val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setSerializable(java.lang.String name,
java.io.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(java.lang.String name,
short val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setString(int position,
java.lang.String val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setString(java.lang.String name,
java.lang.String val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setText(int position,
java.lang.String val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setText(java.lang.String name,
java.lang.String val)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
default Query<R> |
setTime(int position,
java.util.Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setTime(java.lang.String name,
java.util.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 in seconds.
|
default Query<R> |
setTimestamp(int position,
java.util.Date val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
default Query<R> |
setTimestamp(java.lang.String name,
java.util.Date value)
Deprecated.
(since 5.2) use
setParameter(String, Object) or setParameter(String, Object, Type)
instead |
java.util.stream.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. |
java.util.Optional<R> |
uniqueResultOptional() |
determineProperBooleanType, determineProperBooleanType, getFlushMode, getNamedParameters, getReturnAliases, getReturnTypes, getTimeout, isCacheable, isReadOnly, iterate
QueryProducer getProducer()
RowSelection getQueryOptions()
java.util.Optional<R> uniqueResultOptional()
java.util.stream.Stream<R> stream()
You should call BaseStream.close()
after processing the stream
so that the underlying resources are deallocated right away.
Query<R> setParameter(javax.persistence.Parameter<java.time.Instant> param, java.time.Instant value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(javax.persistence.Parameter<java.time.LocalDateTime> param, java.time.LocalDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(javax.persistence.Parameter<java.time.ZonedDateTime> param, java.time.ZonedDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(javax.persistence.Parameter<java.time.OffsetDateTime> param, java.time.OffsetDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(java.lang.String name, java.time.Instant value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(java.lang.String name, java.time.LocalDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(java.lang.String name, java.time.ZonedDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(java.lang.String name, java.time.OffsetDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(int position, java.time.Instant value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(int position, java.time.LocalDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(int position, java.time.ZonedDateTime value, javax.persistence.TemporalType temporalType)
Query<R> setParameter(int position, java.time.OffsetDateTime value, javax.persistence.TemporalType temporalType)
ScrollableResults scroll()
Query
You should call ScrollableResults.close()
after processing the ScrollableResults
so that the underlying resources are deallocated right away.
ScrollableResults
ScrollableResults scroll(ScrollMode scrollMode)
Query
You should call ScrollableResults.close()
after processing the ScrollableResults
so that the underlying resources are deallocated right away.
scrollMode
- The scroll modeScrollableResults
,
ScrollMode
java.util.List<R> list()
Query
default java.util.List<R> getResultList()
getResultList
in interface javax.persistence.Query
getResultList
in interface javax.persistence.TypedQuery<R>
R uniqueResult()
Query
null
if the query returns no results.default R getSingleResult()
getSingleResult
in interface javax.persistence.Query
getSingleResult
in interface javax.persistence.TypedQuery<R>
FlushMode getHibernateFlushMode()
Query
getHibernateFlushMode
in interface BasicQueryContract
FlushMode
CacheMode getCacheMode()
Query
getCacheMode
in interface BasicQueryContract
Session.getCacheMode()
,
CacheMode
java.lang.String getCacheRegion()
Query
Query.isCacheable()
for more information). null
indicates that the
default region should be used.getCacheRegion
in interface BasicQueryContract
null
indicates
the default region.java.lang.Integer getFetchSize()
Query
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
Statement.getFetchSize()
,
Statement.setFetchSize(int)
LockOptions getLockOptions()
Query
LockOptions
java.lang.String getComment()
Query
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.java.lang.String getQueryString()
Query
ParameterMetadata getParameterMetadata()
Query
Query<R> setMaxResults(int maxResult)
setMaxResults
in interface javax.persistence.Query
setMaxResults
in interface javax.persistence.TypedQuery<R>
Query<R> setFirstResult(int startPosition)
setFirstResult
in interface javax.persistence.Query
setFirstResult
in interface javax.persistence.TypedQuery<R>
Query<R> setHint(java.lang.String hintName, java.lang.Object value)
setHint
in interface javax.persistence.Query
setHint
in interface javax.persistence.TypedQuery<R>
<T> Query<R> setParameter(javax.persistence.Parameter<T> param, T value)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(javax.persistence.Parameter<java.util.Calendar> param, java.util.Calendar value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(javax.persistence.Parameter<java.util.Date> param, java.util.Date value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(java.lang.String name, java.lang.Object value)
Query
Query.setParameter(String, Object, Type)
should be used insteadsetParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
name
- the parameter namevalue
- the (possibly-null) parameter valuethis
, for method chainingQuery<R> setParameter(java.lang.String name, java.lang.Object val, Type type)
Query
name
- the name of the parameterval
- the possibly-null parameter valuetype
- the Hibernate typethis
, for method chainingQuery<R> setParameter(java.lang.String name, java.util.Calendar value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(java.lang.String name, java.util.Date value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(int position, java.lang.Object value)
Query
Query.setParameter(int, Object, Type)
should be used insteadsetParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
position
- the position of the parameter in the query
string, numbered from 0.value
- the possibly-null parameter valuethis
, for method chainingQuery<R> setParameter(int position, java.util.Calendar value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
Query<R> setParameter(int position, java.util.Date value, javax.persistence.TemporalType temporalType)
setParameter
in interface javax.persistence.Query
setParameter
in interface javax.persistence.TypedQuery<R>
<T> Query<R> setParameter(QueryParameter<T> parameter, T val)
Query
Query.setParameter(QueryParameter, Object, Type)
should be used insteadparameter
- The query parameter mementoval
- the possibly-null parameter valuethis
, for method chaining<P> Query<R> setParameter(int position, P val, javax.persistence.TemporalType temporalType)
Query
position
- the position of the parameter in the query
string, numbered from 0.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)
Query
parameter
- The query parameter mementoval
- the possibly-null parameter valuetype
- the Hibernate typethis
, for method chainingQuery<R> setParameter(int position, java.lang.Object val, Type type)
Query
position
- the position of the parameter in the query
string, numbered from 0.val
- the possibly-null parameter valuetype
- the Hibernate typethis
, for method chaining<P> Query<R> setParameter(QueryParameter<P> parameter, P val, javax.persistence.TemporalType temporalType)
Query
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(java.lang.String name, P val, javax.persistence.TemporalType temporalType)
Query
name
- the parameter nameval
- the possibly-null parameter valuetemporalType
- the temporal-type to use in binding the date/timethis
, for method chainingQuery<R> setFlushMode(javax.persistence.FlushModeType flushMode)
setFlushMode
in interface javax.persistence.Query
setFlushMode
in interface javax.persistence.TypedQuery<R>
Query<R> setLockMode(javax.persistence.LockModeType lockMode)
setLockMode
in interface javax.persistence.Query
setLockMode
in interface javax.persistence.TypedQuery<R>
Query<R> setReadOnly(boolean readOnly)
Query
setReadOnly
in interface BasicQueryContract
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 chainingTo set the default read-only/modifiable setting used for
entities and proxies that are loaded into the session:
,
PersistenceContext.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 before the query was executed.
Query<R> setHibernateFlushMode(FlushMode flushMode)
Query
setHibernateFlushMode
in interface BasicQueryContract
flushMode
- The new FlushMode to use.this
, for method chainingQuery.getHibernateFlushMode()
Query<R> setCacheMode(CacheMode cacheMode)
Query
setCacheMode
in interface BasicQueryContract
cacheMode
- The new CacheMode to use.this
, for method chainingQuery.getCacheMode()
Query<R> setCacheable(boolean cacheable)
Query
setCacheable
in interface BasicQueryContract
cacheable
- Should the query results be cacheable?this
, for method chainingQuery.isCacheable()
Query<R> setCacheRegion(java.lang.String cacheRegion)
Query
setCacheRegion
in interface BasicQueryContract
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)
Query
setTimeout
in interface BasicQueryContract
timeout
- the timeout in secondsthis
, for method chainingQuery.getTimeout()
Query<R> setFetchSize(int fetchSize)
Query
setFetchSize
in interface BasicQueryContract
fetchSize
- the fetch size hintthis
, for method chainingQuery.getFetchSize()
Query<R> setLockOptions(LockOptions lockOptions)
Query
Query.setLockMode(String, LockMode)
.lockOptions
- The lock options to apply to the query.this
, for method chainingQuery.getLockOptions()
Query<R> setLockMode(java.lang.String alias, LockMode lockMode)
Query
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(java.lang.String comment)
Query
comment
- The human-readable commentthis
, for method chainingQuery.getComment()
Query<R> addQueryHint(java.lang.String hint)
Query
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, java.util.Collection<P> values)
Query
parameter
- the parameter mementovalues
- a collection of values to listthis
, for method chainingQuery<R> setParameterList(java.lang.String name, java.util.Collection values)
Query
name
- the name of the parametervalues
- a collection of values to listthis
, for method chainingQuery<R> setParameterList(java.lang.String name, java.util.Collection values, Type type)
Query
name
- the name of the parametervalues
- a collection of values to listtype
- the Hibernate type of the valuesthis
, for method chainingQuery<R> setParameterList(java.lang.String name, java.lang.Object[] values, Type type)
Query
name
- the name of the parametervalues
- a collection of values to listtype
- the Hibernate type of the valuesthis
, for method chainingQuery<R> setParameterList(java.lang.String name, java.lang.Object[] values)
Query
name
- the name of the parametervalues
- a collection of values to listthis
, for method chainingQuery<R> setProperties(java.lang.Object bean)
Query
bean
- any JavaBean or POJOthis
, for method chainingQuery<R> setProperties(java.util.Map bean)
Query
bean
- a java.util.Mapthis
, for method chaining@Deprecated default Query<R> setFlushMode(FlushMode flushMode)
setHibernateFlushMode(org.hibernate.FlushMode)
insteadsetFlushMode
in interface BasicQueryContract
flushMode
- The new FlushMode to use.this
, for method chaininggetHibernateFlushMode()
@Deprecated default Query<R> setString(int position, java.lang.String val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- 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)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setText(int position, java.lang.String val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setSerializable(int position, java.io.Serializable val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setLocale(int position, java.util.Locale val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBigDecimal(int position, java.math.BigDecimal val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBigInteger(int position, java.math.BigInteger val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setDate(int position, java.util.Date val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setTime(int position, java.util.Date val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setTimestamp(int position, java.util.Date val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setCalendar(int position, java.util.Calendar val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setCalendarDate(int position, java.util.Calendar val)
setParameter(int, Object)
or setParameter(int, Object, Type)
insteadposition
- The parameter positionval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setString(java.lang.String name, java.lang.String val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setCharacter(java.lang.String name, char val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBoolean(java.lang.String name, boolean val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setByte(java.lang.String name, byte val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setShort(java.lang.String name, short val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setInteger(java.lang.String name, int val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setLong(java.lang.String name, long val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setFloat(java.lang.String name, float val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setDouble(java.lang.String name, double val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBinary(java.lang.String name, byte[] val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setText(java.lang.String name, java.lang.String val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setSerializable(java.lang.String name, java.io.Serializable val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setLocale(java.lang.String name, java.util.Locale val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBigDecimal(java.lang.String name, java.math.BigDecimal val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setBigInteger(java.lang.String name, java.math.BigInteger val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter nameval
- The bind valuethis
, for method chaining@Deprecated default Query<R> setDate(java.lang.String name, java.util.Date val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The name of the parameterval
- The val objectthis
, for method chaining@Deprecated default Query<R> setTime(java.lang.String name, java.util.Date val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The name of the parameterval
- The val objectthis
, for method chaining@Deprecated default Query<R> setTimestamp(java.lang.String name, java.util.Date value)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The name of the parametervalue
- The value objectthis
, for method chaining@Deprecated default Query<R> setCalendar(java.lang.String name, java.util.Calendar value)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter namevalue
- The bind valuethis
, for method chaining@Deprecated default Query<R> setCalendarDate(java.lang.String name, java.util.Calendar value)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadname
- The parameter namevalue
- The bind valuethis
, for method chaining@Deprecated Query<R> setEntity(int position, java.lang.Object val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadsetParameter(int, Object)
for null values.position
- the position of the parameter in the query
string, numbered from 0.val
- a non-null instance of a persistent classthis
, for method chaining@Deprecated Query<R> setEntity(java.lang.String name, java.lang.Object val)
setParameter(String, Object)
or setParameter(String, Object, Type)
insteadsetParameter(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)
transformer
- The transformer to apply@Deprecated default Query<R> setParameters(java.lang.Object[] values, Type[] types)
types
- The typesvalues
- The valuesthis
, for method chainingCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.