站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

AbstractQueryImpl (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.impl
Class AbstractQueryImpl

java.lang.Object
  extended bynet.sf.hibernate.impl.AbstractQueryImpl
All Implemented Interfaces:
Query
Direct Known Subclasses:
QueryImpl, SQLQueryImpl

public abstract class AbstractQueryImpl
extends Object
implements Query

Abstract implementation of the Query interface

Author:
Gavin King, Max Andersen

Constructor Summary
AbstractQueryImpl(String queryString, SessionImplementor session)
           
 
Method Summary
protected  String bindParameterLists(Map namedParamsCopy)
           
protected  Map getNamedParameterLists()
           
 String[] getNamedParameters()
          Return the names of all named parameters of the query.
protected  Map getNamedParams()
           
 QueryParameters getQueryParameters(Map namedParams)
           
 String getQueryString()
          Get the query string.
 Type[] getReturnTypes()
          Return the Hibernate types of the query result set.
protected  RowSelection getRowSelection()
           
 RowSelection getSelection()
           
protected  List getTypes()
           
protected  List getValues()
           
 Query setBigDecimal(int position, BigDecimal number)
           
 Query setBigDecimal(String name, BigDecimal 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 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 setDate(int position, Date date)
           
 Query setDate(String name, Date date)
           
 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 setEnum(int position, Object val)
          Bind an instance of a persistent enumeration class to a JDBC-style query parameter.
 Query setEnum(String name, Object val)
          Bind an instance of a mapped persistent enumeration 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 setForceCacheRefresh(boolean forceCacheRefresh)
          Should the query force a refresh of the specified query cache region? This is particularly useful in cases where underlying data may have been updated via a seperate process (i.e., not modified through Hibernate) and allows the application to selectively refresh the query cache regions based on its knowledge of those events.
 Query setInteger(int position, int val)
           
 Query setInteger(String name, int val)
           
 Query setLocale(int position, Locale locale)
           
 Query setLocale(String name, Locale locale)
           
 void setLockMode(String alias, 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(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, guessing the Hibernate type from the class of the given object.
 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, guessing the Hibernate type from the class of the given object.
 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, guessing the Hibernate type from the class of the first object in the collection.
 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, guessing the Hibernate type from the class of the first object in the array.
 Query setParameterList(String name, Object[] vals, Type type)
          Bind multiple values to a named query parameter.
 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 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)
           
 Query setTimeout(int timeout)
          Set a timeout for the underlying JDBC query.
 Query setTimestamp(int position, Date date)
           
 Query setTimestamp(String name, Date date)
           
 Type[] typeArray()
           
 Object uniqueResult()
          Convenience method to return a single instance that matches the query, or null if the query returns no results.
 Object[] valueArray()
           
protected  void verifyParameters()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.Query
iterate, list, scroll, scroll
 

Constructor Detail

AbstractQueryImpl

public AbstractQueryImpl(String queryString,
                         SessionImplementor session)
Method Detail

getQueryString

public final String getQueryString()
Description copied from interface: Query
Get the query string.

Specified by:
getQueryString in interface Query
Returns:
the query string

getNamedParams

protected Map getNamedParams()

verifyParameters

protected void verifyParameters()
                         throws HibernateException
Throws:
HibernateException

getNamedParameterLists

protected Map getNamedParameterLists()

getValues

protected List getValues()

getTypes

protected List getTypes()

getSelection

public RowSelection getSelection()

setMaxResults

public Query setMaxResults(int maxResults)
Description copied from interface: Query
Set the maximum number of rows to retrieve. If not set, there is no limit to the number of rows retrieved.

Specified by:
setMaxResults in interface Query
Parameters:
maxResults - the maximum number of rows

setTimeout

public Query setTimeout(int timeout)
Description copied from interface: Query
Set a timeout for the underlying JDBC query.

Specified by:
setTimeout in interface Query
Parameters:
timeout - the timeout in seconds

setFetchSize

public Query setFetchSize(int fetchSize)
Description copied from interface: Query
Set a fetch size for the underlying JDBC query.

Specified by:
setFetchSize in interface Query
Parameters:
fetchSize - the fetch size

setFirstResult

public Query setFirstResult(int firstResult)
Description copied from interface: Query
Set the first row to retrieve. If not set, rows will be retrieved beginnning from row 0.

Specified by:
setFirstResult in interface Query
Parameters:
firstResult - a row number, numbered from 0

setParameter

public Query setParameter(int position,
                          Object val,
                          Type type)
Description copied from interface: Query
Bind a value to a JDBC-style query parameter.

Specified by:
setParameter in interface Query
Parameters:
position - the position of the parameter in the query string, numbered from 0.
val - the possibly-null parameter value
type - the Hibernate type

setString

public Query setString(int position,
                       String val)
Specified by:
setString in interface Query

setCharacter

public Query setCharacter(int position,
                          char val)
Specified by:
setCharacter in interface Query

setBoolean

public Query setBoolean(int position,
                        boolean val)
Specified by:
setBoolean in interface Query

setByte

public Query setByte(int position,
                     byte val)
Specified by:
setByte in interface Query

setShort

public Query setShort(int position,
                      short val)
Specified by:
setShort in interface Query

setInteger

public Query setInteger(int position,
                        int val)
Specified by:
setInteger in interface Query

setLong

public Query setLong(int position,
                     long val)
Specified by:
setLong in interface Query

setFloat

public Query setFloat(int position,
                      float val)
Specified by:
setFloat in interface Query

setDouble

public Query setDouble(int position,
                       double val)
Specified by:
setDouble in interface Query

setBinary

public Query setBinary(int position,
                       byte[] val)
Specified by:
setBinary in interface Query

setText

public Query setText(int position,
                     String val)
Specified by:
setText in interface Query

setSerializable

public Query setSerializable(int position,
                             Serializable val)
Specified by:
setSerializable in interface Query

setDate

public Query setDate(int position,
                     Date date)
Specified by:
setDate in interface Query

setTime

public Query setTime(int position,
                     Date date)
Specified by:
setTime in interface Query

setTimestamp

public Query setTimestamp(int position,
                          Date date)
Specified by:
setTimestamp in interface Query

setEntity

public Query setEntity(int position,
                       Object val)
Description copied from interface: Query
Bind an instance of a mapped persistent class to a JDBC-style query parameter.

Specified by:
setEntity in interface Query
Parameters:
position - the position of the parameter in the query string, numbered from 0.
val - a non-null instance of a persistent class

setEnum

public Query setEnum(int position,
                     Object val)
              throws MappingException
Description copied from interface: Query
Bind an instance of a persistent enumeration class to a JDBC-style query parameter.

Specified by:
setEnum in interface Query
Parameters:
position - the position of the parameter in the query string, numbered from 0.
val - a non-null instance of a persistent enumeration
Throws:
MappingException

setLocale

public Query setLocale(int position,
                       Locale locale)
Specified by:
setLocale in interface Query

setCalendar

public Query setCalendar(int position,
                         Calendar calendar)
Specified by:
setCalendar in interface Query

setCalendarDate

public Query setCalendarDate(int position,
                             Calendar calendar)
Specified by:
setCalendarDate in interface Query

setBinary

public Query setBinary(String name,
                       byte[] val)
Specified by:
setBinary in interface Query

setText

public Query setText(String name,
                     String val)
Specified by:
setText in interface Query

setBoolean

public Query setBoolean(String name,
                        boolean val)
Specified by:
setBoolean in interface Query

setByte

public Query setByte(String name,
                     byte val)
Specified by:
setByte in interface Query

setCharacter

public Query setCharacter(String name,
                          char val)
Specified by:
setCharacter in interface Query

setDate

public Query setDate(String name,
                     Date date)
Specified by:
setDate in interface Query

setDouble

public Query setDouble(String name,
                       double val)
Specified by:
setDouble in interface Query

setEntity

public Query setEntity(String name,
                       Object val)
Description copied from interface: Query
Bind an instance of a mapped persistent class to a named query parameter.

Specified by:
setEntity in interface Query
Parameters:
name - the name of the parameter
val - a non-null instance of a persistent class

setEnum

public Query setEnum(String name,
                     Object val)
              throws MappingException
Description copied from interface: Query
Bind an instance of a mapped persistent enumeration class to a named query parameter.

Specified by:
setEnum in interface Query
Parameters:
name - the name of the parameter
val - a non-null instance of a persistent enumeration
Throws:
MappingException

setFloat

public Query setFloat(String name,
                      float val)
Specified by:
setFloat in interface Query

setInteger

public Query setInteger(String name,
                        int val)
Specified by:
setInteger in interface Query

setLocale

public Query setLocale(String name,
                       Locale locale)
Specified by:
setLocale in interface Query

setCalendar

public Query setCalendar(String name,
                         Calendar calendar)
Specified by:
setCalendar in interface Query

setCalendarDate

public Query setCalendarDate(String name,
                             Calendar calendar)
Specified by:
setCalendarDate in interface Query

setLong

public Query setLong(String name,
                     long val)
Specified by:
setLong in interface Query

setParameter

public Query setParameter(String name,
                          Object val,
                          Type type)
Description copied from interface: Query
Bind a value to a named query parameter.

Specified by:
setParameter in interface Query
Parameters:
name - the name of the parameter
val - the possibly-null parameter value
type - the Hibernate type

setSerializable

public Query setSerializable(String name,
                             Serializable val)
Specified by:
setSerializable in interface Query

setShort

public Query setShort(String name,
                      short val)
Specified by:
setShort in interface Query

setString

public Query setString(String name,
                       String val)
Specified by:
setString in interface Query

setTime

public Query setTime(String name,
                     Date date)
Specified by:
setTime in interface Query

setTimestamp

public Query setTimestamp(String name,
                          Date date)
Specified by:
setTimestamp in interface Query

setBigDecimal

public Query setBigDecimal(int position,
                           BigDecimal number)
Specified by:
setBigDecimal in interface Query

setBigDecimal

public Query setBigDecimal(String name,
                           BigDecimal number)
Specified by:
setBigDecimal in interface Query

setParameter

public Query setParameter(int position,
                          Object val)
                   throws HibernateException
Description copied from interface: Query
Bind a value to a JDBC-style query parameter, guessing the Hibernate type from the class of the given object.

Specified by:
setParameter in interface Query
Parameters:
position - the position of the parameter in the query string, numbered from 0.
val - the non-null parameter value
Throws:
HibernateException - if no type could be determined

setParameter

public Query setParameter(String name,
                          Object val)
                   throws HibernateException
Description copied from interface: Query
Bind a value to a named query parameter, guessing the Hibernate type from the class of the given object.

Specified by:
setParameter in interface Query
Parameters:
name - the name of the parameter
val - the non-null parameter value
Throws:
HibernateException - if no type could be determined

getReturnTypes

public Type[] getReturnTypes()
                      throws HibernateException
Description copied from interface: Query
Return the Hibernate types of the query result set.

Specified by:
getReturnTypes in interface Query
Returns:
an array of types
Throws:
HibernateException

setParameterList

public Query setParameterList(String name,
                              Collection vals,
                              Type type)
                       throws HibernateException
Description copied from interface: Query
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).

Specified by:
setParameterList in interface Query
Parameters:
name - the name of the parameter
vals - a collection of values to list
type - the Hibernate type of the values
Throws:
HibernateException

bindParameterLists

protected String bindParameterLists(Map namedParamsCopy)

setParameterList

public Query setParameterList(String name,
                              Collection vals)
                       throws HibernateException
Description copied from interface: Query
Bind multiple values to a named query parameter, guessing the Hibernate type from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).

Specified by:
setParameterList in interface Query
Parameters:
name - the name of the parameter
vals - a collection of values to list
Throws:
HibernateException

getNamedParameters

public String[] getNamedParameters()
                            throws HibernateException
Description copied from interface: Query
Return the names of all named parameters of the query.

Specified by:
getNamedParameters in interface Query
Returns:
the parameter names, in no particular order
Throws:
HibernateException

setProperties

public Query setProperties(Object bean)
                    throws HibernateException
Description copied from interface: Query
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.

Specified by:
setProperties in interface Query
Parameters:
bean - any JavaBean or POJO
Throws:
HibernateException

setParameterList

public Query setParameterList(String name,
                              Object[] vals,
                              Type type)
                       throws HibernateException
Description copied from interface: Query
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).

Specified by:
setParameterList in interface Query
Parameters:
name - the name of the parameter
vals - a collection of values to list
type - the Hibernate type of the values
Throws:
HibernateException

setParameterList

public Query setParameterList(String name,
                              Object[] vals)
                       throws HibernateException
Description copied from interface: Query
Bind multiple values to a named query parameter, guessing the Hibernate type from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).

Specified by:
setParameterList in interface Query
Parameters:
name - the name of the parameter
vals - a collection of values to list
Throws:
HibernateException

setLockMode

public void setLockMode(String alias,
                        LockMode lockMode)
Description copied from interface: Query
Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.

Specified by:
setLockMode in interface Query
Parameters:
alias - a query alias, or this for a collection filter

uniqueResult

public Object uniqueResult()
                    throws HibernateException
Description copied from interface: Query
Convenience method to return a single instance that matches the query, or null if the query returns no results.

Specified by:
uniqueResult in interface Query
Returns:
the single result or null
Throws:
HibernateException - if there is more than one matching result

getRowSelection

protected RowSelection getRowSelection()

typeArray

public Type[] typeArray()

valueArray

public Object[] valueArray()

getQueryParameters

public QueryParameters getQueryParameters(Map namedParams)

setCacheable

public Query setCacheable(boolean cacheable)
Description copied from interface: Query
Enable caching of this query result set.

Specified by:
setCacheable in interface Query
Parameters:
cacheable - Should the query results be cacheable?

setCacheRegion

public Query setCacheRegion(String cacheRegion)
Description copied from interface: Query
Set the name of the cache region.

Specified by:
setCacheRegion in interface Query
Parameters:
cacheRegion - the name of a query cache region, or null for the default query cache

setForceCacheRefresh

public Query setForceCacheRefresh(boolean forceCacheRefresh)
Description copied from interface: Query
Should the query force a refresh of the specified query cache region? This is particularly useful in cases where underlying data may have been updated via a seperate process (i.e., not modified through Hibernate) and allows the application to selectively refresh the query cache regions based on its knowledge of those events.

Specified by:
setForceCacheRefresh in interface Query
Parameters:
forceCacheRefresh - Should the query result in a forceable refresh of the query cache?