|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Query
An object-oriented representation of a Hibernate query. A Query instance is obtained by calling Session.createQuery(). This interface exposes some extra functionality beyond that provided by Session.iterate() and Session.find():
SharedSessionContract.createQuery(java.lang.String)
,
ScrollableResults
Method Summary | |
---|---|
int |
executeUpdate()
Execute the update or delete statement. |
String[] |
getNamedParameters()
Return the names of all named parameters of the query. |
String |
getQueryString()
Get the query string. |
String[] |
getReturnAliases()
Return the HQL select clause aliases (if any) |
Type[] |
getReturnTypes()
Return the Hibernate types of the query result set. |
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. |
Iterator |
iterate()
Return the query results as an Iterator. |
List |
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. |
Query |
setBigDecimal(int position,
BigDecimal number)
|
Query |
setBigDecimal(String name,
BigDecimal number)
|
Query |
setBigInteger(int position,
BigInteger number)
|
Query |
setBigInteger(String name,
BigInteger number)
|
Query |
setBinary(int position,
byte[] val)
|
Query |
setBinary(String name,
byte[] val)
|
Query |
setBoolean(int position,
boolean val)
|
Query |
setBoolean(String name,
boolean val)
|
Query |
setByte(int position,
byte val)
|
Query |
setByte(String name,
byte val)
|
Query |
setCacheable(boolean cacheable)
Enable caching of this query result set. |
Query |
setCacheMode(CacheMode cacheMode)
Override the current session cache mode, just for this query. |
Query |
setCacheRegion(String cacheRegion)
Set the name of the cache region. |
Query |
setCalendar(int position,
Calendar calendar)
|
Query |
setCalendar(String name,
Calendar calendar)
|
Query |
setCalendarDate(int position,
Calendar calendar)
|
Query |
setCalendarDate(String name,
Calendar calendar)
|
Query |
setCharacter(int position,
char val)
|
Query |
setCharacter(String name,
char val)
|
Query |
setComment(String comment)
Add a comment to the generated SQL. |
Query |
setDate(int position,
Date date)
|
Query |
setDate(String name,
Date date)
Bind the date (time is truncated) of a given Date object to a named query parameter. |
Query |
setDouble(int position,
double val)
|
Query |
setDouble(String name,
double val)
|
Query |
setEntity(int position,
Object val)
Bind an instance of a mapped persistent class to a JDBC-style query parameter. |
Query |
setEntity(String name,
Object val)
Bind an instance of a mapped persistent class to a named query parameter. |
Query |
setFetchSize(int fetchSize)
Set a fetch size for the underlying JDBC query. |
Query |
setFirstResult(int firstResult)
Set the first row to retrieve. |
Query |
setFloat(int position,
float val)
|
Query |
setFloat(String name,
float val)
|
Query |
setFlushMode(FlushMode flushMode)
Override the current session flush mode, just for this query. |
Query |
setInteger(int position,
int val)
|
Query |
setInteger(String name,
int val)
|
Query |
setLocale(int position,
Locale locale)
|
Query |
setLocale(String name,
Locale locale)
|
Query |
setLockMode(String alias,
LockMode lockMode)
Set the lockmode for the objects idententified by the given alias that appears in the FROM clause. |
Query |
setLockOptions(LockOptions lockOptions)
Set the lock options for the objects idententified by the given alias that appears in the FROM clause. |
Query |
setLong(int position,
long val)
|
Query |
setLong(String name,
long val)
|
Query |
setMaxResults(int maxResults)
Set the maximum number of rows to retrieve. |
Query |
setParameter(int position,
Object val)
Bind a value to a JDBC-style query parameter. |
Query |
setParameter(int position,
Object val,
Type type)
Bind a value to a JDBC-style query parameter. |
Query |
setParameter(String name,
Object val)
Bind a value to a named query parameter. |
Query |
setParameter(String name,
Object val,
Type type)
Bind a value to a named query parameter. |
Query |
setParameterList(String name,
Collection vals)
Bind multiple values to a named query parameter. |
Query |
setParameterList(String name,
Collection vals,
Type type)
Bind multiple values to a named query parameter. |
Query |
setParameterList(String name,
Object[] vals)
Bind multiple values to a named query parameter. |
Query |
setParameterList(String name,
Object[] vals,
Type type)
Bind multiple values to a named query parameter. |
Query |
setParameters(Object[] values,
Type[] types)
Bind values and types to positional parameters. |
Query |
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 hueristics. |
Query |
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 hueristics. |
Query |
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies loaded by this Query. |
Query |
setResultTransformer(ResultTransformer transformer)
Set a strategy for handling the query results. |
Query |
setSerializable(int position,
Serializable val)
|
Query |
setSerializable(String name,
Serializable val)
|
Query |
setShort(int position,
short val)
|
Query |
setShort(String name,
short val)
|
Query |
setString(int position,
String val)
|
Query |
setString(String name,
String val)
|
Query |
setText(int position,
String val)
|
Query |
setText(String name,
String val)
|
Query |
setTime(int position,
Date date)
|
Query |
setTime(String name,
Date date)
Bind the time (date is truncated) of a given Date object to a named query parameter. |
Query |
setTimeout(int timeout)
Set a timeout for the underlying JDBC query. |
Query |
setTimestamp(int position,
Date date)
|
Query |
setTimestamp(String name,
Date date)
Bind the date and the time of a given Date object to a named query parameter. |
Object |
uniqueResult()
Convenience method to return a single instance that matches the query, or null if the query returns no results. |
Method Detail |
---|
String getQueryString()
Type[] getReturnTypes() throws HibernateException
HibernateException
String[] getReturnAliases() throws HibernateException
HibernateException
String[] getNamedParameters() throws HibernateException
HibernateException
Iterator iterate() throws HibernateException
HibernateException
ScrollableResults scroll() throws HibernateException
HibernateException
ScrollableResults
ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException
HibernateException
ScrollableResults
,
ScrollMode
List list() throws HibernateException
HibernateException
Object uniqueResult() throws HibernateException
NonUniqueResultException
- if there is more than one matching result
HibernateException
int executeUpdate() throws HibernateException
HibernateException
Query setMaxResults(int maxResults)
maxResults
- the maximum number of rowsQuery setFirstResult(int firstResult)
firstResult
- a row number, numbered from 0boolean isReadOnly()
setReadOnly(boolean)
,
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 setReadOnly(boolean readOnly)
readOnly
- true, entities and proxies loaded by the query will be put in read-only mode
false, entities and proxies loaded by the query will be put in modifiable modeTo 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 setCacheable(boolean cacheable)
cacheable
- Should the query results be cacheable?Query setCacheRegion(String cacheRegion)
cacheRegion
- the name of a query cache region, or null
for the default query cacheQuery setTimeout(int timeout)
timeout
- the timeout in secondsQuery setFetchSize(int fetchSize)
fetchSize
- the fetch sizeQuery setLockOptions(LockOptions lockOptions)
Query setLockMode(String alias, LockMode lockMode)
alias
- a query alias, or this for a collection filterQuery setComment(String comment)
comment
- a human-readable stringQuery setFlushMode(FlushMode flushMode)
FlushMode
Query setCacheMode(CacheMode cacheMode)
CacheMode
Query setParameter(int position, Object val, Type type)
position
- the position of the parameter in the query
string, numbered from 0.val
- the possibly-null parameter valuetype
- the Hibernate typeQuery setParameter(String name, Object val, Type type)
name
- the name of the parameterval
- the possibly-null parameter valuetype
- the Hibernate typeQuery setParameter(int position, Object val) throws HibernateException
position
- the position of the parameter in the query
string, numbered from 0.val
- the non-null parameter value
HibernateException
- if no type could be determinedQuery setParameter(String name, Object val) throws HibernateException
name
- the name of the parameterval
- the non-null parameter value
HibernateException
- if no type could be determinedQuery setParameters(Object[] values, Type[] types) throws HibernateException
HibernateException
Query setParameterList(String name, Collection vals, Type type) throws HibernateException
name
- the name of the parametervals
- a collection of values to listtype
- the Hibernate type of the values
HibernateException
Query setParameterList(String name, Collection vals) throws HibernateException
name
- the name of the parametervals
- a collection of values to list
HibernateException
Query setParameterList(String name, Object[] vals, Type type) throws HibernateException
name
- the name of the parametervals
- a collection of values to listtype
- the Hibernate type of the values
HibernateException
Query setParameterList(String name, Object[] vals) throws HibernateException
name
- the name of the parametervals
- a collection of values to list
HibernateException
Query setProperties(Object bean) throws HibernateException
bean
- any JavaBean or POJO
HibernateException
Query setProperties(Map bean) throws HibernateException
bean
- a java.util.Map
HibernateException
Query setString(int position, String val)
Query setCharacter(int position, char val)
Query setBoolean(int position, boolean val)
Query setByte(int position, byte val)
Query setShort(int position, short val)
Query setInteger(int position, int val)
Query setLong(int position, long val)
Query setFloat(int position, float val)
Query setDouble(int position, double val)
Query setBinary(int position, byte[] val)
Query setText(int position, String val)
Query setSerializable(int position, Serializable val)
Query setLocale(int position, Locale locale)
Query setBigDecimal(int position, BigDecimal number)
Query setBigInteger(int position, BigInteger number)
Query setDate(int position, Date date)
Query setTime(int position, Date date)
Query setTimestamp(int position, Date date)
Query setCalendar(int position, Calendar calendar)
Query setCalendarDate(int position, Calendar calendar)
Query setString(String name, String val)
Query setCharacter(String name, char val)
Query setBoolean(String name, boolean val)
Query setByte(String name, byte val)
Query setShort(String name, short val)
Query setInteger(String name, int val)
Query setLong(String name, long val)
Query setFloat(String name, float val)
Query setDouble(String name, double val)
Query setBinary(String name, byte[] val)
Query setText(String name, String val)
Query setSerializable(String name, Serializable val)
Query setLocale(String name, Locale locale)
Query setBigDecimal(String name, BigDecimal number)
Query setBigInteger(String name, BigInteger number)
Query setDate(String name, Date date)
name
- The name of the parameterdate
- The date objectQuery setTime(String name, Date date)
name
- The name of the parameterdate
- The date objectQuery setTimestamp(String name, Date date)
name
- The name of the parameterdate
- The date objectQuery setCalendar(String name, Calendar calendar)
Query setCalendarDate(String name, Calendar calendar)
Query setEntity(int position, Object val)
position
- the position of the parameter in the query
string, numbered from 0.val
- a non-null instance of a persistent classQuery setEntity(String name, Object val)
name
- the name of the parameterval
- a non-null instance of a persistent classQuery setResultTransformer(ResultTransformer transformer)
transformer
- The transformer to apply
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |