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

public Class QueryLoader

extends BasicLoader
Class Inheritance
Imports
java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.Arrays, .Collections, .HashMap, .Iterator, .List, .Map, java.util.concurrent.TimeUnit, org.hibernate.HibernateException, .LockMode, .LockOptions, .QueryException, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.QueryParameters, .SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.event.spi.EventSource, org.hibernate.hql.internal.HolderInstantiator, org.hibernate.hql.internal.ast.QueryTranslatorImpl, org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression, .FromElement, .QueryNode, .SelectClause, org.hibernate.hql.spi.ParameterInformation, org.hibernate.internal.IteratorImpl, org.hibernate.internal.util.collections.ArrayHelper, org.hibernate.loader.BasicLoader, org.hibernate.loader.internal.AliasConstantsHelper, org.hibernate.loader.spi.AfterLoadAction, org.hibernate.param.ParameterSpecification, org.hibernate.persister.collection.CollectionPersister, .QueryableCollection, org.hibernate.persister.entity.Loadable, .Lockable, .Queryable, org.hibernate.query.spi.ScrollableResultsImplementor, org.hibernate.stat.spi.StatisticsImplementor, org.hibernate.transform.ResultTransformer, org.hibernate.type.EntityType, .Type

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 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<String, String>
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
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Creates a new Loader implementation.

Method Summary

Modifier and TypeMethod and Description
protected String
applyLocks(String sql, QueryParameters parameters, Dialect dialect, List<AfterLoadAction> afterLoadActions)

Overrides org.hibernate.loader.Loader.applyLocks.

Append FOR UPDATE OF clause, if necessary.
protected void
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 SharedSessionContractImplementor
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 explicitly here through the ParameterSpecification interface.
protected HolderInstantiator
buildHolderInstantiator(ResultTransformer queryLocalResultTransformer)

protected 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[]
public boolean[][]
getEntityEagerPerPropertyFetches()

Overrides org.hibernate.loader.Loader.getEntityEagerPerPropertyFetches.

An array indicating for each entity which specific properties must have eager fetching enabled.
protected boolean[]
getEntityEagerPropertyFetches()

Overrides org.hibernate.loader.Loader.getEntityEagerPropertyFetches.

An array indicating whether the entities have eager property fetching enabled for all of their properties.
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, SharedSessionContractImplementor session)

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

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

Overrides org.hibernate.loader.Loader.getResultRowAliases.

Returns the aliases that corresponding to a result row.
public String[]
public String
getSQLString()

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

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

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

Deprecated as a consequence of EventSource being deprecated.
public List<E>
protected boolean
needsFetchingScroll()

Overrides org.hibernate.loader.Loader.needsFetchingScroll.

Does the result set to be scrolled contain collection fetches?
private static Integer
propertyIndexInOrigin(FromElement element, Queryable originPersister)

Deprecated as a consequence of FromElement being deprecated.
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 ScrollableResultsImplementor
scroll(final QueryParameters queryParameters, final SharedSessionContractImplementor 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
entityEagerPerPropertyFetchesback to summary
private boolean[][] entityEagerPerPropertyFetches
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<String, String> 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)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

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, QueryParameters parameters, Dialect dialect, List<AfterLoadAction> afterLoadActions) 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.

Annotations
@Override
applyPostLoadLocksback to summary
protected void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SharedSessionContractImplementor session)

Overrides org.hibernate.loader.Loader.applyPostLoadLocks.

Annotations
@Override
bindParameterValuesback to summary
protected int bindParameterValues(final PreparedStatement statement, final QueryParameters queryParameters, final int startIndex, final SharedSessionContractImplementor 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 explicitly 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:SharedSessionContractImplementor

The originating session.

Returns:int

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

Annotations
@Override
Exceptions
SQLException:
Indicates problems performing the binding.
buildHolderInstantiatorback to summary
protected HolderInstantiator buildHolderInstantiator(ResultTransformer queryLocalResultTransformer)
checkQueryback to summary
protected 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

Annotations
@Override
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.

Annotations
@Override
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

Annotations
@Override
getCollectionSuffixesback to summary
public String[] getCollectionSuffixes()

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

Annotations
@Override
getEntityEagerPerPropertyFetchesback to summary
public boolean[][] getEntityEagerPerPropertyFetches()

Overrides org.hibernate.loader.Loader.getEntityEagerPerPropertyFetches.

Doc from org.hibernate.loader.Loader.getEntityEagerPerPropertyFetches.

An array indicating for each entity which specific properties must have eager fetching enabled.

Superseded by getEntityEagerPropertyFetches().

Returns:boolean[][]

Eager property fetching indicators.

Annotations
@Override
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 for all of their properties.

Supersedes getEntityEagerPerPropertyFetches().

Returns:boolean[]

Eager property fetching indicators.

Annotations
@Override
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.

Annotations
@Override
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

Annotations
@Override
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.

Annotations
@Override
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.

Annotations
@Override
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).

Annotations
@Override
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

Annotations
@Override
getResultColumnOrRowback to summary
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SharedSessionContractImplementor 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.

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

Overrides org.hibernate.loader.Loader.getResultList.

Annotations
@SuppressWarnings:unchecked
@Override
getResultRowback to summary
protected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException

Overrides org.hibernate.loader.Loader.getResultRow.

Annotations
@Override
getResultRowAliasesback to summary
protected String[] getResultRowAliases()

Overrides org.hibernate.loader.Loader.getResultRowAliases.

Doc from org.hibernate.loader.Loader.getResultRowAliases.

Returns the aliases that corresponding to a result row.

Returns:String[]

Returns the aliases that corresponding to a result row.

Annotations
@Override
getSqlAliasSuffixesback to summary
public String[] getSqlAliasSuffixes()
getSQLStringback to summary
public 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.

Annotations
@Override
getSuffixesback to summary
public String[] getSuffixes()

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

Annotations
@Override
hasSelectNewback to summary
protected boolean hasSelectNew()
includeInResultRowback to summary
protected boolean[] includeInResultRow()

Overrides org.hibernate.loader.Loader.includeInResultRow.

Annotations
@Override
initializeback to summary
private void initialize(SelectClause selectClause)
isSubselectLoadingEnabledback to summary
protected boolean isSubselectLoadingEnabled()

Overrides org.hibernate.loader.Loader.isSubselectLoadingEnabled.

Annotations
@Override
iterateback to summary
public Iterator<E> iterate(QueryParameters queryParameters, EventSource session) throws HibernateException

Deprecated

as a consequence of EventSource being deprecated. See corresponding docs for further information.

listback to summary
public List<E> list(SharedSessionContractImplementor 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.

Annotations
@Override
propertyIndexInOriginback to summary
private static Integer propertyIndexInOrigin(FromElement element, Queryable originPersister)

Deprecated

as a consequence of FromElement being deprecated. See corresponding docs for further information.

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

Annotations
@Override
scrollback to summary
public ScrollableResultsImplementor scroll(final QueryParameters queryParameters, final SharedSessionContractImplementor 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

Annotations
@Override
validateScrollabilityback to summary
public final void validateScrollability() throws HibernateException