org.hibernate.impl
Class SQLQueryImpl

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

public class SQLQueryImpl
extends AbstractQueryImpl
implements SQLQuery

Implementation of the SQLQuery contract.

Author:
Max Andersen, Steve Ebersole

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hibernate.SQLQuery
SQLQuery.FetchReturn, SQLQuery.ReturnProperty, SQLQuery.RootReturn
 
Field Summary
 
Fields inherited from class org.hibernate.impl.AbstractQueryImpl
parameterMetadata, session
 
Method Summary
 SQLQuery addEntity(Class entityType)
          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.FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName)
          Declare a join fetch result.
 SQLQuery addJoin(String alias, String path)
          Declare a join fetch result.
 SQLQuery addJoin(String alias, String path, LockMode lockMode)
          Declare a join fetch result, specifying a lock mode
 SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName)
          Declare a join fetch result.
 SQLQuery.RootReturn addRoot(String tableAlias, Class entityType)
          Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition
 SQLQuery.RootReturn addRoot(String tableAlias, String entityName)
          Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition
 SQLQuery addScalar(String columnAlias)
          Declare a scalar query result.
 SQLQuery addScalar(String columnAlias, Type type)
          Declare a scalar query result.
 SQLQuery addSynchronizedEntityClass(Class entityClass)
          Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking.
 SQLQuery addSynchronizedEntityName(String entityName)
          Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking.
 SQLQuery addSynchronizedQuerySpace(String querySpace)
          Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking
 int executeUpdate()
          Execute the update or delete statement.
 LockOptions getLockOptions()
           
 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.
 Query setLockOptions(LockOptions lockOptions)
          Set the lock options for the objects idententified by the given alias that appears in the FROM clause.
 SQLQuery setResultSetMapping(String name)
          Use a predefined named result-set mapping.
protected  void verifyParameters()
          Perform parameter validation.
 
Methods inherited from class org.hibernate.impl.AbstractQueryImpl
after, before, determineType, determineType, determineType, determineType, determineType, expandParameterLists, getCacheMode, getNamedParameterLists, getNamedParameters, getNamedParams, getParameterMetadata, 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, isReadOnly, 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
Returns:
an array of aliases as strings
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
Returns:
an array of types
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

setLockOptions

public Query setLockOptions(LockOptions lockOptions)
Description copied from interface: Query
Set the lock options for the objects idententified by the given alias that appears in the FROM clause.

Specified by:
setLockOptions in interface Query

getLockOptions

public LockOptions getLockOptions()
Specified by:
getLockOptions in class AbstractQueryImpl

addScalar

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

Functions like <return-scalar/> in hbm.xml or ColumnResult

Specified by:
addScalar in interface SQLQuery
Parameters:
columnAlias - The column alias in the result-set to be processed as a scalar result
type - The Hibernate type as which to treat the value.
Returns:
this, for method chaining

addScalar

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

Functions like <return-scalar/> in hbm.xml or ColumnResult

Specified by:
addScalar in interface SQLQuery
Parameters:
columnAlias - The column alias in the result-set to be processed as a scalar result
Returns:
this, for method chaining

addRoot

public SQLQuery.RootReturn addRoot(String tableAlias,
                                   String entityName)
Description copied from interface: SQLQuery
Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition

Specified by:
addRoot in interface SQLQuery
Parameters:
tableAlias - The SQL table alias to map to this entity
entityName - The name of the entity.
Returns:
The return config object for further control.

addRoot

public SQLQuery.RootReturn addRoot(String tableAlias,
                                   Class entityType)
Description copied from interface: SQLQuery
Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition

Specified by:
addRoot in interface SQLQuery
Parameters:
tableAlias - The SQL table alias to map to this entity
entityType - The java type of the entity.
Returns:
The return config object for further control.

addEntity

public SQLQuery addEntity(String entityName)
Description copied from interface: SQLQuery
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name

Use SQLQuery.addRoot(java.lang.String, java.lang.String) if you need further control of the mapping

Specified by:
addEntity in interface SQLQuery
Parameters:
entityName - The entity name that is the root return of the query.
Returns:
this, for method chaining

addEntity

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

Specified by:
addEntity in interface SQLQuery
Parameters:
alias - The SQL table alias
entityName - The entity name
Returns:
this, for method chaining

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
Parameters:
alias - The SQL table alias
entityName - The entity name
lockMode - The lock mode for this return.
Returns:
this, for method chaining

addEntity

public SQLQuery addEntity(Class entityType)
Description copied from interface: SQLQuery
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name

Specified by:
addEntity in interface SQLQuery
Parameters:
entityType - The java type of the entity to add as a root
Returns:
this, for method chaining

addEntity

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

Specified by:
addEntity in interface SQLQuery
Parameters:
alias - The SQL table alias
entityClass - The java type of the entity to add as a root
Returns:
this, for method chaining

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
Parameters:
alias - The SQL table alias
entityClass - The entity name
lockMode - The lock mode for this return.
Returns:
this, for method chaining

addFetch

public SQLQuery.FetchReturn addFetch(String tableAlias,
                                     String ownerTableAlias,
                                     String joinPropertyName)
Description copied from interface: SQLQuery
Declare a join fetch result.

Specified by:
addFetch in interface SQLQuery
Parameters:
tableAlias - The SQL table alias for the data to be mapped to this fetch
ownerTableAlias - Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetch
joinPropertyName - The name of the property being join fetched.
Returns:
The return config object for further control.

addJoin

public SQLQuery addJoin(String tableAlias,
                        String ownerTableAlias,
                        String joinPropertyName)
Description copied from interface: SQLQuery
Declare a join fetch result.

Specified by:
addJoin in interface SQLQuery
Parameters:
tableAlias - The SQL table alias for the data to be mapped to this fetch
ownerTableAlias - Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetch
joinPropertyName - The name of the property being join fetched.
Returns:
this, for method chaining

addJoin

public SQLQuery addJoin(String alias,
                        String path)
Description copied from interface: SQLQuery
Declare a join fetch result.

Specified by:
addJoin in interface SQLQuery
Parameters:
alias - The SQL table alias for the data to be mapped to this fetch
path - The association path ([owner-alias].[property-name]).
Returns:
this, for method chaining

addJoin

public SQLQuery addJoin(String alias,
                        String path,
                        LockMode lockMode)
Description copied from interface: SQLQuery
Declare a join fetch result, specifying a lock mode

Specified by:
addJoin in interface SQLQuery
Parameters:
alias - The SQL table alias for the data to be mapped to this fetch
path - The association path ([owner-alias].[property-name]).
lockMode - The lock mode for this return.
Returns:
this, for method chaining

setResultSetMapping

public SQLQuery setResultSetMapping(String name)
Description copied from interface: SQLQuery
Use a predefined named result-set mapping. This might be defined by a <result-set/> element in a Hibernate hbm.xml file or through a SqlResultSetMapping annotation.

Specified by:
setResultSetMapping in interface SQLQuery
Parameters:
name - The name of the mapping to use.
Returns:
this, for method chaining

addSynchronizedQuerySpace

public SQLQuery addSynchronizedQuerySpace(String querySpace)
Description copied from interface: SQLQuery
Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking

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

addSynchronizedEntityName

public SQLQuery addSynchronizedEntityName(String entityName)
Description copied from interface: SQLQuery
Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same as SQLQuery.addSynchronizedQuerySpace(java.lang.String) for all tables associated with the given entity.

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 chaining

addSynchronizedEntityClass

public SQLQuery addSynchronizedEntityClass(Class entityClass)
Description copied from interface: SQLQuery
Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same as SQLQuery.addSynchronizedQuerySpace(java.lang.String) for all tables associated with the given entity.

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 chaining

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


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.