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