Top Description Fields Constructors Methods
org.hibernate.loader.hql

public Class QueryLoader

extends BasicLoader
Class Inheritance
Imports
java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.HashMap, .HashSet, .Iterator, .List, .Map, org.hibernate.HibernateException, .LockMode, .QueryException, .ScrollableResults, .LockOptions, org.hibernate.dialect.Dialect, org.hibernate.engine.EntityEntry, .QueryParameters, .SessionFactoryImplementor, .SessionImplementor, org.hibernate.event.EventSource, org.hibernate.exception.JDBCExceptionHelper, org.hibernate.hql.HolderInstantiator, org.hibernate.hql.ast.QueryTranslatorImpl, org.hibernate.hql.ast.tree.FromElement, .SelectClause, .QueryNode, .AggregatedSelectExpression, org.hibernate.impl.IteratorImpl, org.hibernate.loader.BasicLoader, org.hibernate.param.ParameterSpecification, org.hibernate.persister.collection.CollectionPersister, .QueryableCollection, org.hibernate.persister.entity.Loadable, .Queryable, .Lockable, org.hibernate.transform.ResultTransformer, org.hibernate.type.EntityType, .Type, org.hibernate.util.ArrayHelper

A delegate that implements the Loader part of QueryTranslator.
Author
josh

Field Summary

Modifier and TypeField and Description
private AggregatedSelectExpression
private int[]
private QueryableCollection[]
private String[]
private LockMode[]
private String[]
private boolean[]
private Queryable[]
private boolean
private boolean[]
private EntityType[]
private int[]
private String[]
private Type[]
private QueryTranslatorImpl
queryTranslator

The query translator that is delegating to this object.

private String[][]
private int
private final Map<K, V>
private String[]
private String[]
Inherited from org.hibernate.loader.BasicLoader:
NO_SUFFIX

Constructor Summary

AccessConstructor and Description
public
QueryLoader(final QueryTranslatorImpl
The query translator that is the delegator.
queryTranslator
,
final SessionFactoryImplementor
The factory from which this loader is being created.
factory
,
final SelectClause
The AST representing the select clause for loading.
selectClause
)

Creates a new Loader implementation.

Method Summary

Modifier and TypeMethod and Description
protected String
applyLocks(String sql, LockOptions lockOptions, Dialect dialect)

Overrides org.hibernate.loader.Loader.applyLocks.

Append FOR UPDATE OF clause, if necessary.
protected void
private int
protected int

Returns:

The number of JDBC bind positions actually bound during this method execution.
bindParameterValues
(final PreparedStatement
The JDBC prepared statement
statement
,
final QueryParameters
The encapsulation of the parameter values to be bound.
queryParameters
,
final int
The position from which to start binding parameter values.
startIndex
,
final SessionImplementor
The originating session.
session
)

Overrides org.hibernate.loader.Loader.bindParameterValues.

We specifically override this method here, because in general we know much more about the parameters and their appropriate bind positions here then we do in our super because we track them explciitly here through the ParameterSpecification interface.
private HolderInstantiator
buildHolderInstantiator(ResultTransformer queryLocalResultTransformer)

private void
checkQuery(QueryParameters queryParameters)

public AggregatedSelectExpression
public String[]
getAliases()

Overrides org.hibernate.loader.Loader.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()

Overrides org.hibernate.loader.Loader.getCollectionOwners.

Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie.
protected CollectionPersister[]
getCollectionPersisters()

Overrides org.hibernate.loader.Loader.getCollectionPersisters.

An (optional) persister for a collection to be initialized; only collection loaders return a non-null value
public String[]
protected boolean[]
getEntityEagerPropertyFetches()

Overrides org.hibernate.loader.Loader.getEntityEagerPropertyFetches.

An array indicating whether the entities have eager property fetching enabled.
public Loadable[]
getEntityPersisters()

Implements abstract org.hibernate.loader.Loader.getEntityPersisters.

An array of persisters of entity classes contained in each row of results; implemented by all subclasses
protected LockMode[]
getLockModes(LockOptions
a collection of lock modes specified dynamically via the Query interface
lockOptions
)

Implements abstract org.hibernate.loader.Loader.getLockModes.

What lock options does this load entities with?
public int[]
getNamedParameterLocs(String name)

Overrides org.hibernate.loader.Loader.getNamedParameterLocs.

Returns the locations of all occurrences of the named parameter.
protected EntityType[]
getOwnerAssociationTypes()

Overrides org.hibernate.loader.Loader.getOwnerAssociationTypes.

An array of the owner types corresponding to the getOwners() returns.
protected int[]
getOwners()

Overrides org.hibernate.loader.Loader.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")
protected String
getQueryIdentifier()

Overrides org.hibernate.loader.Loader.getQueryIdentifier.

Identifies the query for statistics reporting, if null, no statistics will be reported
protected Object
getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

Get the actual object that is returned in the user-visible result list.
protected List<E>
public String[]
protected String
getSQLString()

Implements abstract org.hibernate.loader.Loader.getSQLString.

The SQL query string to be called.
public String[]
private boolean
private void
initialize(SelectClause selectClause)

protected boolean
public Iterator<E>
iterate(QueryParameters queryParameters, EventSource session)

public List<E>
list(SessionImplementor session, QueryParameters queryParameters)

protected boolean
needsFetchingScroll()

Overrides org.hibernate.loader.Loader.needsFetchingScroll.

Does the result set to be scrolled contain collection fetches?
protected ResultTransformer
resolveResultTransformer(ResultTransformer
the specified result transformer
resultTransformer
)

Overrides org.hibernate.loader.Loader.resolveResultTransformer.

Determine the actual ResultTransformer that will be used to transform query results.
public ScrollableResults
scroll(final QueryParameters queryParameters, final SessionImplementor session)

private Object[]
protected boolean
upgradeLocks()

Overrides org.hibernate.loader.Loader.upgradeLocks.

Does this query return objects that might be already cached by the session, whose lock mode may need upgrading
public final void
Inherited from org.hibernate.loader.BasicLoader:
generateSuffixesgenerateSuffixesgetCollectionAliasesgetEntityAliasespostInstantiate

Field Detail

aggregatedSelectExpressionback to summary
private AggregatedSelectExpression aggregatedSelectExpression
collectionOwnersback to summary
private int[] collectionOwners
collectionPersistersback to summary
private QueryableCollection[] collectionPersisters
collectionSuffixesback to summary
private String[] collectionSuffixes
defaultLockModesback to summary
private LockMode[] defaultLockModes
entityAliasesback to summary
private String[] entityAliases
entityEagerPropertyFetchesback to summary
private boolean[] entityEagerPropertyFetches
entityPersistersback to summary
private Queryable[] entityPersisters
hasScalarsback to summary
private boolean hasScalars
includeInSelectback to summary
private boolean[] includeInSelect
ownerAssociationTypesback to summary
private EntityType[] ownerAssociationTypes
ownersback to summary
private int[] owners
queryReturnAliasesback to summary
private String[] queryReturnAliases
queryReturnTypesback to summary
private Type[] queryReturnTypes
queryTranslatorback to summary
private QueryTranslatorImpl queryTranslator

The query translator that is delegating to this object.

scalarColumnNamesback to summary
private String[][] scalarColumnNames
selectLengthback to summary
private int selectLength
sqlAliasByEntityAliasback to summary
private final Map<K, V> sqlAliasByEntityAlias
sqlAliasesback to summary
private String[] sqlAliases
sqlAliasSuffixesback to summary
private String[] sqlAliasSuffixes

Constructor Detail

QueryLoaderback to summary
public QueryLoader(final QueryTranslatorImpl queryTranslator, final SessionFactoryImplementor factory, final SelectClause selectClause)

Creates a new Loader implementation.

Parameters
queryTranslator:QueryTranslatorImpl

The query translator that is the delegator.

factory:SessionFactoryImplementor

The factory from which this loader is being created.

selectClause:SelectClause

The AST representing the select clause for loading.

Method Detail

applyLocksback to summary
protected String applyLocks(String sql, LockOptions lockOptions, Dialect dialect) throws QueryException

Overrides org.hibernate.loader.Loader.applyLocks.

Doc from org.hibernate.loader.Loader.applyLocks.

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

applyPostLoadLocksback to summary
protected void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session)

Overrides org.hibernate.loader.Loader.applyPostLoadLocks.

bindFilterParameterValuesback to summary
private int bindFilterParameterValues(PreparedStatement st, QueryParameters queryParameters, int position, SessionImplementor session) throws SQLException
bindParameterValuesback to summary
protected int bindParameterValues(final PreparedStatement statement, final QueryParameters queryParameters, final int startIndex, final SessionImplementor session) throws SQLException

Overrides org.hibernate.loader.Loader.bindParameterValues.

We specifically override this method here, because in general we know much more about the parameters and their appropriate bind positions here then we do in our super because we track them explciitly here through the ParameterSpecification interface.

Parameters
statement:PreparedStatement

Doc from org.hibernate.loader.Loader.bindParameterValues.

The JDBC prepared statement

queryParameters:QueryParameters

The encapsulation of the parameter values to be bound.

startIndex:int

The position from which to start binding parameter values.

session:SessionImplementor

The originating session.

Returns:int

The number of JDBC bind positions actually bound during this method execution.

Exceptions
SQLException:
Indicates problems performing the binding.
buildHolderInstantiatorback to summary
private HolderInstantiator buildHolderInstantiator(ResultTransformer queryLocalResultTransformer)
checkQueryback to summary
private void checkQuery(QueryParameters queryParameters)
getAggregatedSelectExpressionback to summary
public AggregatedSelectExpression getAggregatedSelectExpression()
getAliasesback to summary
public String[] getAliases()

Overrides org.hibernate.loader.Loader.getAliases.

Doc from org.hibernate.loader.Loader.getAliases.

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

getCollectionOwnersback to summary
protected int[] getCollectionOwners()

Overrides org.hibernate.loader.Loader.getCollectionOwners.

Doc from org.hibernate.loader.Loader.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.

getCollectionPersistersback to summary
protected CollectionPersister[] getCollectionPersisters()

Overrides org.hibernate.loader.Loader.getCollectionPersisters.

An (optional) persister for a collection to be initialized; only collection loaders return a non-null value

getCollectionSuffixesback to summary
public String[] getCollectionSuffixes()

Implements abstract org.hibernate.loader.BasicLoader.getCollectionSuffixes.

getEntityEagerPropertyFetchesback to summary
protected boolean[] getEntityEagerPropertyFetches()

Overrides org.hibernate.loader.Loader.getEntityEagerPropertyFetches.

Doc from org.hibernate.loader.Loader.getEntityEagerPropertyFetches.

An array indicating whether the entities have eager property fetching enabled.

Returns:boolean[]

Eager property fetching indicators.

getEntityPersistersback to summary
public Loadable[] getEntityPersisters()

Implements abstract org.hibernate.loader.Loader.getEntityPersisters.

Doc from org.hibernate.loader.Loader.getEntityPersisters.

An array of persisters of entity classes contained in each row of results; implemented by all subclasses

Returns:Loadable[]

The entity persisters.

getLockModesback to summary
protected LockMode[] getLockModes(LockOptions lockOptions)

Implements abstract org.hibernate.loader.Loader.getLockModes.

Doc from org.hibernate.loader.Loader.getLockModes.

What lock options does this load entities with?

Parameters
lockOptions:LockOptions

a collection of lock modes specified dynamically via the Query interface

getNamedParameterLocsback to summary
public int[] getNamedParameterLocs(String name) throws QueryException

Overrides org.hibernate.loader.Loader.getNamedParameterLocs.

Returns the locations of all occurrences of the named parameter.

getOwnerAssociationTypesback to summary
protected EntityType[] getOwnerAssociationTypes()

Overrides org.hibernate.loader.Loader.getOwnerAssociationTypes.

Doc from org.hibernate.loader.Loader.getOwnerAssociationTypes.

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

Returns:EntityType[]

The types for the owners.

getOwnersback to summary
protected int[] getOwners()

Overrides org.hibernate.loader.Loader.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")

Returns:int[]

Doc from org.hibernate.loader.Loader.getOwners.

The owner indicators (see discussion above).

getQueryIdentifierback to summary
protected String getQueryIdentifier()

Overrides org.hibernate.loader.Loader.getQueryIdentifier.

Doc from org.hibernate.loader.Loader.getQueryIdentifier.

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

getResultColumnOrRowback to summary
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

Doc from org.hibernate.loader.Loader.getResultColumnOrRow.

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.

getResultListback to summary
protected List<E> getResultList(List<E> results, ResultTransformer resultTransformer) throws QueryException

Overrides org.hibernate.loader.Loader.getResultList.

getSqlAliasSuffixesback to summary
public String[] getSqlAliasSuffixes()
getSQLStringback to summary
protected String getSQLString()

Implements abstract org.hibernate.loader.Loader.getSQLString.

The SQL query string to be called.

Returns:String

Doc from org.hibernate.loader.Loader.getSQLString.

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

getSuffixesback to summary
public String[] getSuffixes()

Implements abstract org.hibernate.loader.BasicLoader.getSuffixes.

hasSelectNewback to summary
private boolean hasSelectNew()
initializeback to summary
private void initialize(SelectClause selectClause)
isSubselectLoadingEnabledback to summary
protected boolean isSubselectLoadingEnabled()

Overrides org.hibernate.loader.Loader.isSubselectLoadingEnabled.

iterateback to summary
public Iterator<E> iterate(QueryParameters queryParameters, EventSource session) throws HibernateException
listback to summary
public List<E> list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException
needsFetchingScrollback to summary
protected boolean needsFetchingScroll()

Overrides org.hibernate.loader.Loader.needsFetchingScroll.

Doc from org.hibernate.loader.Loader.needsFetchingScroll.

Does the result set to be scrolled contain collection fetches?

Returns:boolean

True if it does, and thus needs the special fetching scroll functionality; false otherwise.

resolveResultTransformerback to summary
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)

Overrides org.hibernate.loader.Loader.resolveResultTransformer.

Doc from org.hibernate.loader.Loader.resolveResultTransformer.

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

Parameters
resultTransformer:ResultTransformer

the specified result transformer

Returns:ResultTransformer

the actual result transformer

scrollback to summary
public ScrollableResults scroll(final QueryParameters queryParameters, final SessionImplementor session) throws HibernateException
toResultRowback to summary
private Object[] toResultRow(Object[] row)
upgradeLocksback to summary
protected boolean upgradeLocks()

Overrides org.hibernate.loader.Loader.upgradeLocks.

Doc from org.hibernate.loader.Loader.upgradeLocks.

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

validateScrollabilityback to summary
public final void validateScrollability() throws HibernateException