Query
instead@Deprecated public interface Query<R> extends TypedQuery<R>, CommonQueryContract
Represents an HQL/JPQL query or a compiled Criteria query
Modifier and Type | Method and Description |
---|---|
Query<R> |
addQueryHint(String hint)
Deprecated.
Add a DB query hint to the SQL.
|
Type |
determineProperBooleanType(int position,
Object value,
Type defaultType)
Deprecated.
added only to allow default method definition for deprecated methods here.
|
Type |
determineProperBooleanType(String name,
Object value,
Type defaultType)
Deprecated.
added only to allow default method definition for deprecated methods here.
|
CacheMode |
getCacheMode()
Deprecated.
Obtain the CacheMode in effect for this query.
|
String |
getCacheRegion()
Deprecated.
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
isCacheable() for more information). |
String |
getComment()
Deprecated.
Obtain the comment currently associated with this query.
|
Integer |
getFetchSize()
Deprecated.
Obtain the JDBC fetch size hint in effect for this query.
|
FlushModeType |
getFlushMode()
Deprecated.
For users of the Hibernate native APIs, we’ve had to rename this method
as defined by Hibernate historically because the JPA contract defines a method of the same
name, but returning the JPA
FlushModeType rather than Hibernate’s FlushMode . |
FlushMode |
getHibernateFlushMode()
Deprecated.
Obtain the FlushMode in effect for this query.
|
LockOptions |
getLockOptions()
Deprecated.
Obtains the LockOptions in effect for this query.
|
String[] |
getNamedParameters()
Deprecated.
(since 5.2) use
ParameterMetadata.getNamedParameterNames() |
ParameterMetadata |
getParameterMetadata()
Deprecated.
Access to information about query parameters.
|
String |
getQueryString()
Deprecated.
Get the query string.
|
String[] |
getReturnAliases()
Deprecated.
(since 5.2) use
Tuple if you need access to "result variables". |
Type[] |
getReturnTypes()
Deprecated.
(since 5.2) with no replacement; to be removed in 6.0
|
Integer |
getTimeout()
Deprecated.
Obtain the query timeout <b>in seconds</b>.
|
boolean |
isCacheable()
Deprecated.
Are the results of this query eligible for second level query caching? This is different that second level
caching of any returned entities and collections.
|
boolean |
isReadOnly()
Deprecated.
Should entities and proxies loaded by this Query be put in read-only mode? If the
read-only/modifiable setting was not initialized, then the default
read-only/modifiable setting for the persistence context is returned instead.
|
Iterator<R> |
iterate()
Deprecated.
Return the query results as an <tt>Iterator</tt>.
|
List<R> |
list()
Deprecated.
Return the query results as a <tt>List</tt>.
|
ScrollableResults |
scroll()
Deprecated.
Return the query results as <tt>ScrollableResults</tt>.
|
ScrollableResults |
scroll(ScrollMode scrollMode)
Deprecated.
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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setCacheable(boolean cacheable)
Deprecated.
Enable/disable second level query (result) caching for this query.
|
Query<R> |
setCacheMode(CacheMode cacheMode)
Deprecated.
(Re)set the current CacheMode in effect for this query.
|
Query<R> |
setCacheRegion(String cacheRegion)
Deprecated.
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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setComment(String comment)
Deprecated.
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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setEntity(int position,
Object val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setEntity(String name,
Object val)
Deprecated.
(since 5.2) use
setParameter(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setFetchSize(int fetchSize)
Deprecated.
Sets a JDBC fetch size hint for the query.
|
Query<R> |
setFirstResult(int startPosition)
Deprecated.
|
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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setFlushMode(FlushMode flushMode)
Deprecated.
(since 5.2) use
setHibernateFlushMode(org.hibernate.FlushMode) instead |
Query<R> |
setFlushMode(FlushModeType flushMode)
Deprecated.
|
default Query<R> |
setHibernateFlushMode(FlushMode flushMode)
Deprecated.
(Re)set the current FlushMode in effect for this query.
|
Query<R> |
setHint(String hintName,
Object value)
Deprecated.
|
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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setLockMode(LockModeType lockMode)
Deprecated.
|
Query<R> |
setLockMode(String alias,
LockMode lockMode)
Deprecated.
Set the LockMode to use for specific alias (as defined in the query’s <tt>FROM</tt> clause).
|
Query<R> |
setLockOptions(LockOptions lockOptions)
Deprecated.
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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setMaxResults(int maxResult)
Deprecated.
|
Query<R> |
setParameter(int position,
Calendar value,
TemporalType temporalType)
Deprecated.
|
Query<R> |
setParameter(int position,
Date value,
TemporalType temporalType)
Deprecated.
|
Query<R> |
setParameter(int position,
Object val)
Deprecated.
Bind a positional query parameter using its inferred Type.
|
Query<R> |
setParameter(int position,
Object val,
Type type)
Deprecated.
Bind a value to a JDBC-style query parameter.
|
<P> Query<R> |
setParameter(int position,
P val,
TemporalType temporalType)
Deprecated.
Bind a positional query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameter(Parameter<Calendar> param,
Calendar value,
TemporalType temporalType)
Deprecated.
|
Query<R> |
setParameter(Parameter<Date> param,
Date value,
TemporalType temporalType)
Deprecated.
|
<T> Query<R> |
setParameter(Parameter<T> param,
T value)
Deprecated.
|
<P> Query<R> |
setParameter(QueryParameter<P> parameter,
P val,
TemporalType temporalType)
Deprecated.
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)
Deprecated.
Bind a query parameter using the supplied Type
|
<T> Query<R> |
setParameter(QueryParameter<T> parameter,
T val)
Deprecated.
Bind a query parameter using its inferred Type.
|
Query<R> |
setParameter(String name,
Calendar value,
TemporalType temporalType)
Deprecated.
|
Query<R> |
setParameter(String name,
Date value,
TemporalType temporalType)
Deprecated.
|
Query<R> |
setParameter(String name,
Object val)
Deprecated.
Bind a named query parameter using its inferred Type.
|
Query<R> |
setParameter(String name,
Object val,
Type type)
Deprecated.
Bind a named query parameter using the supplied Type
|
<P> Query<R> |
setParameter(String name,
P val,
TemporalType temporalType)
Deprecated.
Bind a named query parameter as some form of date/time using
the indicated temporal-type.
|
Query<R> |
setParameterList(int position,
Collection values)
Deprecated.
|
Query<R> |
setParameterList(int position,
Collection values,
Type type)
Deprecated.
|
Query<R> |
setParameterList(int position,
Object[] values)
Deprecated.
|
Query<R> |
setParameterList(int position,
Object[] values,
Type type)
Deprecated.
|
<P> Query<R> |
setParameterList(QueryParameter<P> parameter,
Collection<P> values)
Deprecated.
Bind multiple values to a query parameter using its inferred Type.
|
Query<R> |
setParameterList(String name,
Collection values)
Deprecated.
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Collection values,
Type type)
Deprecated.
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Object[] values)
Deprecated.
Bind multiple values to a named query parameter.
|
Query<R> |
setParameterList(String name,
Object[] values,
Type type)
Deprecated.
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)
Deprecated.
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)
Deprecated.
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)
Deprecated.
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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, 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(int, Object) or setParameter(int, Object, Type)
instead |
Query<R> |
setTimeout(int timeout)
Deprecated.
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(int, Object) or setParameter(int, Object, Type)
instead |
R |
uniqueResult()
Deprecated.
Convenience method to return a single instance that matches
the query, or
null if the query returns no results. |
getResultList, getResultStream, getSingleResult
executeUpdate, getFirstResult, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrap
String getQueryString()
Get the query string.
FlushMode getHibernateFlushMode()
Obtain 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
FlushMode
default Query<R> setHibernateFlushMode(FlushMode flushMode)
(Re)set the current FlushMode in effect for this query.
setHibernateFlushMode
in interface BasicQueryContract
flushMode
- The new FlushMode to use.this
, for method chaininggetHibernateFlushMode()
@Deprecated Query<R> setFlushMode(FlushMode flushMode)
setHibernateFlushMode(org.hibernate.FlushMode)
instead(Re)set the current FlushMode in effect for this query.
setFlushMode
in interface BasicQueryContract
flushMode
- The new FlushMode to use.this
, for method chaininggetHibernateFlushMode()
FlushModeType getFlushMode()
For users of the Hibernate native APIs, we’ve had to rename this method
as defined by Hibernate historically because the JPA contract defines a method of the same
name, but returning the JPA FlushModeType
rather than Hibernate’s FlushMode
. For
the former behavior, use Query.getHibernateFlushMode()
instead.
getFlushMode
in interface Query
CacheMode getCacheMode()
Obtain 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
Session.getCacheMode()
,
CacheMode
Query<R> setCacheMode(CacheMode cacheMode)
(Re)set the current CacheMode in effect for this query.
setCacheMode
in interface BasicQueryContract
cacheMode
- The new CacheMode to use.this
, for method chaininggetCacheMode()
boolean isCacheable()
Are the results of this query eligible for second level query caching? This is different that second level caching of any returned entities and collections.
Note
|
the query being "eligible" for caching does not necessarily mean its results will be cached. Second level
query caching still has to be enabled on the SessionFactory for this to happen. Usually that is
controlled by the hibernate.cache.use_query_cache configuration setting.
|
isCacheable
in interface BasicQueryContract
true
if the query results are eligible for caching, false
otherwise.AvailableSettings.USE_QUERY_CACHE
Query<R> setCacheable(boolean cacheable)
Enable/disable second level query (result) caching for this query.
setCacheable
in interface BasicQueryContract
cacheable
- Should the query results be cacheable?this
, for method chainingisCacheable()
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 isCacheable()
for more information). null
indicates that the
default region should be used.
getCacheRegion
in interface BasicQueryContract
null
indicates
the default region.Query<R> setCacheRegion(String cacheRegion)
Set the name of the cache region where query results should be cached (if cached at all).
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 chaininggetCacheRegion()
Integer getTimeout()
Obtain the query timeout <b>in seconds</b>. This value is eventually passed along to the JDBC query via
Statement.setQueryTimeout(int)
. Zero indicates no timeout.
getTimeout
in interface BasicQueryContract
Statement.getQueryTimeout()
,
Statement.setQueryTimeout(int)
Query<R> setTimeout(int timeout)
Set 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
timeout
- the timeout <b>in seconds</b>this
, for method chaininggetTimeout()
Integer getFetchSize()
Obtain 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
Statement.getFetchSize()
,
Statement.setFetchSize(int)
Query<R> setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.
setFetchSize
in interface BasicQueryContract
fetchSize
- the fetch size hintthis
, for method chaininggetFetchSize()
boolean isReadOnly()
Should entities and proxies loaded by this Query be put in read-only mode? If the read-only/modifiable setting was not initialized, then the default read-only/modifiable setting for the persistence context is returned instead.
isReadOnly
in interface BasicQueryContract
true
if the entities and proxies loaded by the query will be put
in read-only mode; false
otherwise (they will be modifiable)setReadOnly(boolean)
,
PersistenceContext.isDefaultReadOnly()
Query<R> setReadOnly(boolean readOnly)
Set 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
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)
@Deprecated Type[] getReturnTypes()
Return the Hibernate types of the query results.
getReturnTypes
in interface BasicQueryContract
LockOptions getLockOptions()
Obtains the LockOptions in effect for this query.
LockOptions
Query<R> setLockOptions(LockOptions lockOptions)
Set 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 setLockMode(String, LockMode)
.
lockOptions
- The lock options to apply to the query.this
, for method chaininggetLockOptions()
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).
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 chaininggetLockOptions()
String getComment()
Obtain 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.
Query<R> setComment(String comment)
Set the comment for this query.
comment
- The human-readable commentthis
, for method chaininggetComment()
Query<R> addQueryHint(String hint)
Add 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.Iterator<R> iterate()
Return the query results as an <tt>Iterator</tt>. If the query contains multiple results per row, the results are returned in an instance of <tt>Object[]</tt>.<br> <br> Entities returned as results are initialized on demand. The first SQL query returns identifiers only.<br>
ScrollableResults scroll()
Return 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.
ScrollableResults
ScrollableResults scroll(ScrollMode scrollMode)
Return 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
,
ScrollMode
List<R> list()
Return 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>.
R uniqueResult()
Convenience method to return a single instance that matches
the query, or null
if the query returns no results.
NonUniqueResultException
- if there is more than one matching resultParameterMetadata getParameterMetadata()
Access to information about query parameters.
@Deprecated String[] getNamedParameters()
ParameterMetadata.getNamedParameterNames()
Return the names of all named parameters of the query.
<T> Query<R> setParameter(QueryParameter<T> parameter, T val)
Bind 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 setParameter(QueryParameter, Object, Type)
should be used instead
parameter
- The query parameter mementoval
- the possibly-null parameter valuethis
, for method chaining<T> Query<R> setParameter(Parameter<T> param, T value)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(String name, Object val)
Bind 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 setParameter(String, Object, Type)
should be used instead
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
name
- the parameter nameval
- the (possibly-null) parameter valuethis
, for method chainingQuery<R> setParameter(int position, Object val)
Bind 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 setParameter(int, Object, Type)
should be used instead
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
position
- the position of the parameter in the query
string, numbered from <tt>0</tt>.val
- the possibly-null parameter valuethis
, for method chaining<P> Query<R> setParameter(QueryParameter<P> parameter, P val, Type type)
Bind 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(String name, Object val, Type type)
Bind 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(int position, Object val, Type type)
Bind 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)
Bind 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)
Bind 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 chaining<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.
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> setParameterList(QueryParameter<P> parameter, Collection<P> values)
Bind 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)
Bind 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(int position, Collection values)
Query<R> setParameterList(String name, Collection values, Type type)
Bind 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(int position, Collection values, Type type)
Query<R> setParameterList(String name, Object[] values, Type type)
Bind 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)
Bind 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)
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.
bean
- any JavaBean or POJOthis
, for method chainingQuery<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.
bean
- a java.util.Mapthis
, for method chainingQuery<R> setMaxResults(int maxResult)
setMaxResults
in interface Query
setMaxResults
in interface TypedQuery<R>
Query<R> setFirstResult(int startPosition)
setFirstResult
in interface Query
setFirstResult
in interface TypedQuery<R>
Query<R> setHint(String hintName, Object value)
setHint
in interface Query
setHint
in interface TypedQuery<R>
Query<R> setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(String name, Calendar value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(String name, Date value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(int position, Calendar value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setParameter(int position, Date value, TemporalType temporalType)
setParameter
in interface Query
setParameter
in interface TypedQuery<R>
Query<R> setFlushMode(FlushModeType flushMode)
setFlushMode
in interface Query
setFlushMode
in interface TypedQuery<R>
Query<R> setLockMode(LockModeType lockMode)
setLockMode
in interface Query
setLockMode
in interface TypedQuery<R>
@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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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(int, Object)
or setParameter(int, 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 Type determineProperBooleanType(int position, Object value, Type defaultType)
@Deprecated Type determineProperBooleanType(String name, Object value, Type defaultType)
@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 String[] getReturnAliases()
Tuple
if you need access to "result variables".@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 chainingCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.