org.hibernate.impl
Class SQLQueryImpl

java.lang.Object
  extended byorg.hibernate.impl.AbstractQueryImpl
      extended byorg.hibernate.impl.SQLQueryImpl
All Implemented Interfaces:
Query, SQLQuery

public class SQLQueryImpl
extends AbstractQueryImpl
implements SQLQuery

Implements SQL query passthrough.

 
 
   SELECT {person}.NAME AS {person.name}, {person}.AGE AS {person.age}, {person}.SEX AS {person.sex}
   FROM PERSON {person} WHERE {person}.NAME LIKE 'Hiber%'
 
 

Author:
Max Andersen

Field Summary
 
Fields inherited from class org.hibernate.impl.AbstractQueryImpl
parameterMetadata, session
 
Method Summary
 SQLQuery addEntity(Class entityClass)
          Declare a "root" entity, without specifying an alias
 SQLQuery addEntity(String entityName)
          Declare a "root" entity, without specifying an alias
 SQLQuery addEntity(String alias, Class entityClass)
          Declare a "root" entity
 SQLQuery addEntity(String alias, Class entityClass, LockMode lockMode)
          Declare a "root" entity, specifying a lock mode
 SQLQuery addEntity(String alias, String entityName)
          Declare a "root" entity
 SQLQuery addEntity(String alias, String entityName, LockMode lockMode)
          Declare a "root" entity, specifying a lock mode
 SQLQuery addJoin(String alias, String path)
          Declare a "joined" entity
 SQLQuery addJoin(String alias, String path, LockMode lockMode)
          Declare a "joined" entity, specifying a lock mode
 SQLQuery addScalar(String columnAlias)
          Declare a scalar query.
 SQLQuery addScalar(String columnAlias, Type type)
          Declare a scalar query result
 SQLQuery addSynchronizedEntityClass(Class entityClass)
          Adds an entity name or auto-flush synchronization.
 SQLQuery addSynchronizedEntityName(String entityName)
          Adds an entity name or auto-flush synchronization.
 SQLQuery addSynchronizedQuerySpace(String querySpace)
          Adds a query space for auto-flush synchronization.
 int executeUpdate()
          Execute the update or delete statement.
protected  Map getLockModes()
           
 QueryParameters getQueryParameters(Map namedParams)
           
 String[] getReturnAliases()
          Return the HQL select clause aliases (if any)
 Type[] getReturnTypes()
          Return the Hibernate types of the query result set.
 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 setLockMode(String alias, LockMode lockMode)
          Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
 SQLQuery setResultSetMapping(String name)
          Use a predefined named ResultSetMapping
protected  void verifyParameters()
          Perform parameter validation.
 
Methods inherited from class org.hibernate.impl.AbstractQueryImpl
after, before, determineType, determineType, determineType, determineType, determineType, expandParameterLists, getNamedParameterLists, getNamedParameters, getNamedParams, getQueryString, getRowSelection, getSelection, getTypes, getValues, hasNamedParameters, isReadOnly, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCacheable, setCacheMode, setCacheRegion, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setCollectionKey, setComment, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFetchSize, setFirstResult, setFloat, setFloat, setFlushMode, setInteger, setInteger, setLocale, setLocale, setLong, setLong, setMaxResults, setOptionalEntityName, setOptionalId, setOptionalObject, setParameter, setParameter, setParameter, setParameter, setParameterList, setParameterList, setParameterList, setParameterList, setParameters, setProperties, setProperties, setReadOnly, setResultTransformer, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimeout, setTimestamp, setTimestamp, toString, typeArray, uniqueResult, valueArray, verifyParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.hibernate.Query
getNamedParameters, getQueryString, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCacheable, setCacheMode, setCacheRegion, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setComment, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFetchSize, setFirstResult, setFloat, setFloat, setFlushMode, setInteger, setInteger, setLocale, setLocale, setLong, setLong, setMaxResults, setParameter, setParameter, setParameter, setParameter, setParameterList, setParameterList, setParameterList, setParameterList, setParameters, setProperties, setProperties, setReadOnly, setResultTransformer, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimeout, setTimestamp, setTimestamp, uniqueResult
 

Method Detail

list

public List list()
          throws HibernateException
Description copied from interface: Query
Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Specified by:
list in interface Query
Returns:
the result list
Throws:
HibernateException

scroll

public ScrollableResults scroll(ScrollMode scrollMode)
                         throws HibernateException
Description copied from interface: Query
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Specified by:
scroll in interface Query
Returns:
the result iterator
Throws:
HibernateException
See Also:
ScrollableResults, ScrollMode

scroll

public ScrollableResults scroll()
                         throws HibernateException
Description copied from interface: Query
Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Specified by:
scroll in interface Query
Returns:
the result iterator
Throws:
HibernateException
See Also:
ScrollableResults

iterate

public Iterator iterate()
                 throws HibernateException
Description copied from interface: Query
Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.

Specified by:
iterate in interface Query
Returns:
the result iterator
Throws:
HibernateException

getQueryParameters

public QueryParameters getQueryParameters(Map namedParams)
Overrides:
getQueryParameters in class AbstractQueryImpl

verifyParameters

protected void verifyParameters()
Description copied from class: AbstractQueryImpl
Perform parameter validation. Used prior to executing the encapsulated query.

Overrides:
verifyParameters in class AbstractQueryImpl

getReturnAliases

public String[] getReturnAliases()
                          throws HibernateException
Description copied from interface: Query
Return the HQL select clause aliases (if any)

Specified by:
getReturnAliases in interface Query
Overrides:
getReturnAliases in class AbstractQueryImpl
Throws:
HibernateException

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
Overrides:
getReturnTypes in class AbstractQueryImpl
Throws:
HibernateException

setLockMode

public Query 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

getLockModes

protected Map getLockModes()
Specified by:
getLockModes in class AbstractQueryImpl

addScalar

public SQLQuery addScalar(String columnAlias,
                          Type type)
Description copied from interface: SQLQuery
Declare a scalar query result

Specified by:
addScalar in interface SQLQuery

addScalar

public SQLQuery addScalar(String columnAlias)
Description copied from interface: SQLQuery
Declare a scalar query. Hibernate will attempt to automatically detect the underlying type.

Specified by:
addScalar in interface SQLQuery

addJoin

public SQLQuery addJoin(String alias,
                        String path)
Description copied from interface: SQLQuery
Declare a "joined" entity

Specified by:
addJoin in interface SQLQuery

addEntity

public SQLQuery addEntity(Class entityClass)
Description copied from interface: SQLQuery
Declare a "root" entity, without specifying an alias

Specified by:
addEntity in interface SQLQuery

addEntity

public SQLQuery addEntity(String entityName)
Description copied from interface: SQLQuery
Declare a "root" entity, without specifying an alias

Specified by:
addEntity in interface SQLQuery

addEntity

public SQLQuery addEntity(String alias,
                          String entityName)
Description copied from interface: SQLQuery
Declare a "root" entity

Specified by:
addEntity in interface SQLQuery

addEntity

public SQLQuery addEntity(String alias,
                          Class entityClass)
Description copied from interface: SQLQuery
Declare a "root" entity

Specified by:
addEntity in interface SQLQuery

addJoin

public SQLQuery addJoin(String alias,
                        String path,
                        LockMode lockMode)
Description copied from interface: SQLQuery
Declare a "joined" entity, specifying a lock mode

Specified by:
addJoin in interface SQLQuery

addEntity

public SQLQuery addEntity(String alias,
                          String entityName,
                          LockMode lockMode)
Description copied from interface: SQLQuery
Declare a "root" entity, specifying a lock mode

Specified by:
addEntity in interface SQLQuery

addEntity

public SQLQuery addEntity(String alias,
                          Class entityClass,
                          LockMode lockMode)
Description copied from interface: SQLQuery
Declare a "root" entity, specifying a lock mode

Specified by:
addEntity in interface SQLQuery

setResultSetMapping

public SQLQuery setResultSetMapping(String name)
Description copied from interface: SQLQuery
Use a predefined named ResultSetMapping

Specified by:
setResultSetMapping in interface SQLQuery

addSynchronizedQuerySpace

public SQLQuery addSynchronizedQuerySpace(String querySpace)
Description copied from interface: SQLQuery
Adds a query space for auto-flush synchronization.

Specified by:
addSynchronizedQuerySpace in interface SQLQuery
Parameters:
querySpace - The query space to be auto-flushed for this query.
Returns:
this, for method chaning

addSynchronizedEntityName

public SQLQuery addSynchronizedEntityName(String entityName)
Description copied from interface: SQLQuery
Adds an entity name or auto-flush synchronization.

Specified by:
addSynchronizedEntityName in interface SQLQuery
Parameters:
entityName - The name of the entity upon whose defined query spaces we should additionally synchronize.
Returns:
this, for method chaning

addSynchronizedEntityClass

public SQLQuery addSynchronizedEntityClass(Class entityClass)
Description copied from interface: SQLQuery
Adds an entity name or auto-flush synchronization.

Specified by:
addSynchronizedEntityClass in interface SQLQuery
Parameters:
entityClass - The class of the entity upon whose defined query spaces we should additionally synchronize.
Returns:
this, for method chaning

executeUpdate

public int executeUpdate()
                  throws HibernateException
Description copied from interface: Query
Execute the update or delete statement.

The semantics are compliant with the ejb3 Query.executeUpdate() method.

Specified by:
executeUpdate in interface Query
Returns:
The number of entities updated or deleted.
Throws:
HibernateException