public class

SQLQueryImpl

extends AbstractQueryImpl
implements SQLQuery
java.lang.Object
   ↳ org.hibernate.impl.AbstractQueryImpl
     ↳ org.hibernate.impl.SQLQueryImpl

Class Overview

Implementation of the SQLQuery contract.

Summary

[Expand]
Inherited Fields
From class org.hibernate.impl.AbstractQueryImpl
Public Methods
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, LockMode lockMode)
Declare a "root" entity, specifying a lock mode
SQLQuery addEntity(String entityName)
Declare a "root" entity, without specifying an alias.
SQLQuery addEntity(String alias, String entityName)
Declare a "root" entity
SQLQuery addEntity(Class entityType)
Declare a "root" entity, without specifying an alias.
SQLQuery.FetchReturn addFetch(String tableAlias, String ownerTableAlias, String joinPropertyName)
Declare a join fetch result.
SQLQuery addJoin(String tableAlias, String ownerTableAlias, String joinPropertyName)
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 alias, String path)
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, Type type)
Declare a scalar query result.
SQLQuery addScalar(String columnAlias)
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(ScrollMode scrollMode)
Return the query results as ScrollableResults.
ScrollableResults scroll()
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 Methods
void verifyParameters()
Perform parameter validation.
[Expand]
Inherited Methods
From class org.hibernate.impl.AbstractQueryImpl
From class java.lang.Object
From interface org.hibernate.Query
From interface org.hibernate.SQLQuery

Public Methods

public SQLQuery addEntity (String alias, Class entityClass)

Declare a "root" entity

Parameters
alias The SQL table alias
entityClass The java type of the entity to add as a root
Returns
  • this, for method chaining

public SQLQuery addEntity (String alias, Class entityClass, LockMode lockMode)

Declare a "root" entity, specifying a lock mode

Parameters
alias The SQL table alias
entityClass The entity name
lockMode The lock mode for this return.
Returns
  • this, for method chaining

public SQLQuery addEntity (String alias, String entityName, LockMode lockMode)

Declare a "root" entity, specifying a lock mode

Parameters
alias The SQL table alias
entityName The entity name
lockMode The lock mode for this return.
Returns
  • this, for method chaining

public SQLQuery addEntity (String entityName)

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 addRoot(String, Class) if you need further control of the mapping

Parameters
entityName The entity name that is the root return of the query.
Returns
  • this, for method chaining

public SQLQuery addEntity (String alias, String entityName)

Declare a "root" entity

Parameters
alias The SQL table alias
entityName The entity name
Returns
  • this, for method chaining

public SQLQuery addEntity (Class entityType)

Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name

Parameters
entityType The java type of the entity to add as a root
Returns
  • this, for method chaining

public SQLQuery.FetchReturn addFetch (String tableAlias, String ownerTableAlias, String joinPropertyName)

Declare a join fetch result.

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.

public SQLQuery addJoin (String tableAlias, String ownerTableAlias, String joinPropertyName)

Declare a join fetch result.

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

public SQLQuery addJoin (String alias, String path, LockMode lockMode)

Declare a join fetch result, specifying a lock mode

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

public SQLQuery addJoin (String alias, String path)

Declare a join fetch result.

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

public SQLQuery.RootReturn addRoot (String tableAlias, Class entityType)

Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition

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.

public SQLQuery.RootReturn addRoot (String tableAlias, String entityName)

Add a new root return mapping, returning a SQLQuery.RootReturn to allow further definition

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.

public SQLQuery addScalar (String columnAlias, Type type)

Declare a scalar query result.

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

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

public SQLQuery addScalar (String columnAlias)

Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type.

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

Parameters
columnAlias The column alias in the result-set to be processed as a scalar result
Returns
  • this, for method chaining

public SQLQuery addSynchronizedEntityClass (Class entityClass)

Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same as addSynchronizedQuerySpace(String) for all tables associated with the given entity.

Parameters
entityClass The class of the entity upon whose defined query spaces we should additionally synchronize.
Returns
  • this, for method chaining

public SQLQuery addSynchronizedEntityName (String entityName)

Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same as addSynchronizedQuerySpace(String) for all tables associated with the given entity.

Parameters
entityName The name of the entity upon whose defined query spaces we should additionally synchronize.
Returns
  • this, for method chaining

public SQLQuery addSynchronizedQuerySpace (String querySpace)

Adds a query space (table name) for (a) auto-flush checking and (b) query result cache invalidation checking

Parameters
querySpace The query space to be auto-flushed for this query.
Returns
  • this, for method chaining

public int executeUpdate ()

Execute the update or delete statement.

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

Returns
  • The number of entities updated or deleted.

public LockOptions getLockOptions ()

public QueryParameters getQueryParameters (Map namedParams)

public String[] getReturnAliases ()

Return the HQL select clause aliases (if any)

Returns
  • an array of aliases as strings

public Type[] getReturnTypes ()

Return the Hibernate types of the query result set.

Returns
  • an array of types

public Iterator iterate ()

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.

Returns
  • the result iterator

public List list ()

Return the query results as a List. If the query contains multiple results pre row, the results are returned in an instance of Object[].

Returns
  • the result list

public ScrollableResults scroll (ScrollMode scrollMode)

Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Returns
  • the result iterator

public ScrollableResults scroll ()

Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.

Returns
  • the result iterator

public Query setLockMode (String alias, LockMode lockMode)

Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.

Parameters
alias a query alias, or this for a collection filter

public Query setLockOptions (LockOptions lockOptions)

Set the lock options for the objects idententified by the given alias that appears in the FROM clause.

public SQLQuery setResultSetMapping (String name)

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 javax.persistence.SqlResultSetMapping annotation.

Parameters
name The name of the mapping to use.
Returns
  • this, for method chaining

Protected Methods

protected void verifyParameters ()

Perform parameter validation. Used prior to executing the encapsulated query.