public class

QueryTranslatorImpl

extends BasicLoader
implements FilterTranslator
java.lang.Object
   ↳ org.hibernate.loader.Loader
     ↳ org.hibernate.loader.BasicLoader
       ↳ org.hibernate.hql.classic.QueryTranslatorImpl

Class Overview

An instance of QueryTranslator translates a Hibernate query string to SQL.

Summary

[Expand]
Inherited Constants
From interface org.hibernate.hql.QueryTranslator
[Expand]
Inherited Fields
From class org.hibernate.loader.BasicLoader
Public Constructors
QueryTranslatorImpl(String queryIdentifier, String queryString, Map enabledFilters, SessionFactoryImplementor factory)
Construct a query translator
QueryTranslatorImpl(String queryString, Map enabledFilters, SessionFactoryImplementor factory)
Construct a query translator; this form used internally.
Public Methods
List collectSqlStrings()
synchronized void compile(Map replacements, boolean scalar)
Compile a "normal" query.
synchronized void compile(String collectionRole, Map replacements, boolean scalar)
Compile a filter.
boolean containsCollectionFetches()
Does the translated query contain collection fetches?
int executeUpdate(QueryParameters queryParameters, SessionImplementor session)
Perform a bulk update/delete operation given the underlying query definition.
String getAliasName(String alias)
CollectionPersister[] getCollectionPersisters()
Overrides method from Loader
String[][] getColumnNames()
Returns the column names in the generated SQL.
Map getEnabledFilters()
Returns the filters enabled for this query translator.
Class getHolderClass()
int[] getNamedParameterLocs(String name)
ParameterTranslations getParameterTranslations()
Return information about any parameters encountered during translation.
String getQueryIdentifier()
Identifies the query for statistics reporting, if null, no statistics will be reported
final Set getQuerySpaces()
Returns the set of query spaces (table names) that the query refers to.
String getQueryString()
Returns the HQL string processed by the translator.
String[] getReturnAliases()
Returns an array of HQL aliases
Type[] getReturnTypes()
Types of the return values of an iterate() style query.
String getSQLString()
The SQL query string to be called; implemented by all subclasses
boolean isManipulationStatement()
Iterator iterate(QueryParameters queryParameters, EventSource session)
Return the query results as an iterator
List list(SessionImplementor session, QueryParameters queryParameters)
Perform a list operation given the underlying query definition.
ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
Perform a scroll operation given the underlying query definition.
String toString()
void validateScrollability()
Validate the scrollability of the translated query.
Protected Methods
String applyLocks(String sql, LockOptions lockOptions, Dialect dialect)
Append FOR UPDATE OF clause, if necessary.
String[] getAliases()
Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading
int[] getCollectionOwners()
Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie.
String[] getCollectionSuffixes()
Loadable[] getEntityPersisters()
Persisters for the return values of a find() style query.
LockMode[] getLockModes(LockOptions lockOptions)
What lock options does this load entities with?
EntityType[] getOwnerAssociationTypes()
An array of the owner types corresponding to the getOwners() returns.
int[] getOwners()
An array of indexes of the entity that owns a one-to-one association to the entity at the given index (-1 if there is no "owner").
Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
Get the actual object that is returned in the user-visible result list.
List getResultList(List results, ResultTransformer resultTransformer)
String[] getSuffixes()
boolean isCompiled()
boolean isSubselectLoadingEnabled()
ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
Determine the actual ResultTransformer that will be used to transform query results.
boolean upgradeLocks()
Does this query return objects that might be already cached by the session, whose lock mode may need upgrading
[Expand]
Inherited Methods
From class org.hibernate.loader.BasicLoader
From class org.hibernate.loader.Loader
From class java.lang.Object
From interface org.hibernate.hql.FilterTranslator
From interface org.hibernate.hql.QueryTranslator

Public Constructors

public QueryTranslatorImpl (String queryIdentifier, String queryString, Map enabledFilters, SessionFactoryImplementor factory)

Construct a query translator

Parameters
queryIdentifier A unique identifier for the query of which this translation is part; typically this is the original, user-supplied query string.
queryString The "preprocessed" query string; at the very least already processed by QuerySplitter.
enabledFilters Any enabled filters.
factory The session factory.

public QueryTranslatorImpl (String queryString, Map enabledFilters, SessionFactoryImplementor factory)

Construct a query translator; this form used internally.

Parameters
queryString The query string to process.
enabledFilters Any enabled filters.
factory The session factory.

Public Methods

public List collectSqlStrings ()

public synchronized void compile (Map replacements, boolean scalar)

Compile a "normal" query. This method may be called multiple times. Subsequent invocations are no-ops.

Parameters
replacements Defined query substitutions.
scalar Does this represent a shallow (scalar or entity-id) select?

public synchronized void compile (String collectionRole, Map replacements, boolean scalar)

Compile a filter. This method may be called multiple times. Subsequent invocations are no-ops.

Parameters
collectionRole the role name of the collection used as the basis for the filter.
replacements Defined query substitutions.
scalar Does this represent a shallow (scalar or entity-id) select?

public boolean containsCollectionFetches ()

Does the translated query contain collection fetches?

Returns
  • true if the query does contain collection fetched; false otherwise.

public int executeUpdate (QueryParameters queryParameters, SessionImplementor session)

Perform a bulk update/delete operation given the underlying query definition.

Parameters
queryParameters The query bind parameters.
session The session owning this query.
Returns
  • The number of entities updated or deleted.

public String getAliasName (String alias)

public CollectionPersister[] getCollectionPersisters ()

Overrides method from Loader

public String[][] getColumnNames ()

Returns the column names in the generated SQL.

Returns
  • the column names in the generated SQL.

public Map getEnabledFilters ()

Returns the filters enabled for this query translator.

Returns
  • Filters enabled for this query execution.

public Class getHolderClass ()

public int[] getNamedParameterLocs (String name)

public ParameterTranslations getParameterTranslations ()

Return information about any parameters encountered during translation.

Returns
  • The parameter information.

public String getQueryIdentifier ()

Identifies the query for statistics reporting, if null, no statistics will be reported

public final Set getQuerySpaces ()

Returns the set of query spaces (table names) that the query refers to.

Returns
  • A set of query spaces (table names).

public String getQueryString ()

Returns the HQL string processed by the translator.

Returns
  • the HQL string processed by the translator.

public String[] getReturnAliases ()

Returns an array of HQL aliases

public Type[] getReturnTypes ()

Types of the return values of an iterate() style query.

Returns
  • an array of Types.

public String getSQLString ()

The SQL query string to be called; implemented by all subclasses

Returns
  • The sql command this loader should use to get its ResultSet.

public boolean isManipulationStatement ()

public Iterator iterate (QueryParameters queryParameters, EventSource session)

Return the query results as an iterator

Parameters
queryParameters The query bind parameters.
session The session owning this query.
Returns
  • An iterator over the query results.

public List list (SessionImplementor session, QueryParameters queryParameters)

Perform a list operation given the underlying query definition.

Parameters
session The session owning this query.
queryParameters The query bind parameters.
Returns
  • The query list results.

public ScrollableResults scroll (QueryParameters queryParameters, SessionImplementor session)

Perform a scroll operation given the underlying query definition.

Parameters
queryParameters The query bind parameters.
session The session owning this query.
Returns
  • The ScrollableResults wrapper around the query results.

public String toString ()

public void validateScrollability ()

Validate the scrollability of the translated query.

Protected Methods

protected String applyLocks (String sql, LockOptions lockOptions, Dialect dialect)

Append FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.

protected String[] getAliases ()

Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading

protected int[] getCollectionOwners ()

Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie. in the case of a collection initializer) or no collection.

protected String[] getCollectionSuffixes ()

protected Loadable[] getEntityPersisters ()

Persisters for the return values of a find() style query.

Returns
  • an array of EntityPersisters.

protected LockMode[] getLockModes (LockOptions lockOptions)

What lock options does this load entities with?

Parameters
lockOptions a collection of lock options specified dynamically via the Query interface

protected EntityType[] getOwnerAssociationTypes ()

An array of the owner types corresponding to the getOwners() returns. Indices indicating no owner would be null here.

Returns
  • The types for the owners.

protected int[] getOwners ()

An array of indexes of the entity that owns a one-to-one association to the entity at the given index (-1 if there is no "owner"). The indexes contained here are relative to the result of getEntityPersisters().

Returns
  • The owner indicators (see discussion above).

protected Object getResultColumnOrRow (Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)

Get the actual object that is returned in the user-visible result list. This empty implementation merely returns its first argument. This is overridden by some subclasses.

protected List getResultList (List results, ResultTransformer resultTransformer)

protected String[] getSuffixes ()

protected boolean isCompiled ()

protected boolean isSubselectLoadingEnabled ()

protected ResultTransformer resolveResultTransformer (ResultTransformer resultTransformer)

Determine the actual ResultTransformer that will be used to transform query results.

Parameters
resultTransformer the specified result transformer
Returns
  • the actual result transformer

protected boolean upgradeLocks ()

Does this query return objects that might be already cached by the session, whose lock mode may need upgrading