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

public Class CustomLoader

extends Loader
Class Inheritance
Known Direct Subclasses
org.hibernate.result.internal.OutputsImpl.CustomLoaderExtension
Imports
java.io.Serializable, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.ArrayList, .HashSet, .List, .Set, org.hibernate.HibernateException, .LockMode, .LockOptions, .QueryException, .Session, org.hibernate.cache.spi.QueryKey, .QueryResultsCache, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.QueryParameters, .SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.hql.internal.HolderInstantiator, org.hibernate.internal.util.StringHelper, org.hibernate.internal.util.collections.ArrayHelper, org.hibernate.loader.CollectionAliases, .EntityAliases, .Loader, org.hibernate.loader.spi.AfterLoadAction, org.hibernate.param.ParameterBinder, org.hibernate.persister.collection.CollectionPersister, .QueryableCollection, org.hibernate.persister.entity.Loadable, .Queryable, org.hibernate.query.spi.ScrollableResultsImplementor, org.hibernate.transform.ResultTransformer, org.hibernate.type.CollectionType, .EntityType, .Type

Extension point for loaders which use a SQL result set with "unexpected" column aliases.
Authors
Gavin King, Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final CollectionAliases[]
private final int[]
private final QueryableCollection[]
private final EntityAliases[]
private final Queryable[]
private final int[]
private boolean[]
private final LockMode[]
private final List<ParameterBinder>
private final Set<Serializable>
private Type[]
private final ResultRowProcessor
private final String
private String[]
Inherited from org.hibernate.loader.Loader:
LOGSELECTSELECT_DISTINCT

Constructor Summary

AccessConstructor and Description
public
CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

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
bindParameterValues(PreparedStatement
The JDBC prepared statement
statement
,
QueryParameters
The encapsulation of the parameter values to be bound.
queryParameters
,
int
The position from which to start binding parameter values.
startIndex
,
SharedSessionContractImplementor
The originating session.
session
)

Overrides org.hibernate.loader.Loader.bindParameterValues.

Bind all parameter values into the prepared statement in preparation for execution.
private Queryable
protected CollectionAliases[]
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
protected EntityAliases[]
getEntityAliases()

Implements abstract org.hibernate.loader.Loader.getEntityAliases.

Get the result set descriptor
protected 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 options specified dynamically via the Query interface
lockOptions
)

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

What lock options does this load entities with?
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
public Set<E>
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.
private String[]
public String
getSQLString()

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

The SQL query string to be called; implemented by all subclasses
protected boolean[]
public List<E>
protected void
putResultInQueryCache(final SharedSessionContractImplementor session, final QueryParameters queryParameters, final Type[] resultTypes, final QueryResultsCache queryCache, final QueryKey key, final List<E> result)

Overrides org.hibernate.loader.Loader.putResultInQueryCache.

Deprecated as a consequence of QueryResultsCache being deprecated.
resultTypes can be overridden by autoDiscoverTypes(ResultSet), *after* list(SharedSessionContractImplementor, QueryParameters) has already been called.
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)

protected void
private void
Inherited from org.hibernate.loader.Loader:
applyPostLoadLocksareResultSetRowsTransformedImmediatelybindNamedParametersbindPositionalParametersbindPreparedStatementcheckScrollabilitycreateCacheableResultTransformercreateSubselectsdetermineFollowOnLockModedoListdoQueryAndInitializeNonLazyCollectionsdoQueryAndInitializeNonLazyCollectionsendCollectionLoadexecuteQueryStatementexecuteQueryStatementextractKeysFromResultSetgenerateQueryKeygetAliasesgetCompositeKeyManyToOneTargetIndicesgetEntityEagerPerPropertyFetchesgetEntityEagerPropertyFetchesgetEntityPersistergetFactorygetLimitHandlergetNamedParameterLocsgetOptionalObjectKeygetOwnerAssociationTypesgetResultFromQueryCachegetResultSetgetResultSetgetRowsFromResultSethandleEmptyCollectionshasSubselectLoadableCollectionsinstanceAlreadyLoadedinstanceNotYetLoadedisSingleRowLoaderisSubselectLoadingEnabledlistloadCollectionloadCollectionBatchloadCollectionSubselectloadEntityloadEntityloadEntityBatchloadEntityBatchloadSequentialRowsForwardloadSequentialRowsReverseloadSingleRowneedsFetchingScrollpostInstantiateprepareQueryStatementpreprocessResultSetpreprocessSQLprocessDistinctKeywordprocessResultSetregisterNonExistsscrollshouldUseFollowOnLockingtoStringupgradeLocks

Field Detail

collectionAliasesback to summary
private final CollectionAliases[] collectionAliases
collectionOwnersback to summary
private final int[] collectionOwners
collectionPersistersback to summary
private final QueryableCollection[] collectionPersisters
entityAliasesback to summary
private final EntityAliases[] entityAliases
entityPersistersback to summary
private final Queryable[] entityPersisters
entiytOwnersback to summary
private final int[] entiytOwners
includeInResultRowback to summary
private boolean[] includeInResultRow
lockModesback to summary
private final LockMode[] lockModes
paramValueBindersback to summary
private final List<ParameterBinder> paramValueBinders
querySpacesback to summary
private final Set<Serializable> querySpaces
resultTypesback to summary
private Type[] resultTypes
rowProcessorback to summary
private final ResultRowProcessor rowProcessor
sqlback to summary
private final String sql
transformerAliasesback to summary
private String[] transformerAliases

Constructor Detail

CustomLoaderback to summary
public CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory)

Deprecated

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

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
autoDiscoverTypesback to summary
protected void autoDiscoverTypes(ResultSet rs)

Overrides org.hibernate.loader.Loader.autoDiscoverTypes.

Annotations
@Override
bindParameterValuesback to summary
protected int bindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session) throws SQLException

Overrides org.hibernate.loader.Loader.bindParameterValues.

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

Bind all parameter values into the prepared statement in preparation for execution.

Parameters
statement:PreparedStatement

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.
determineAppropriateOwnerPersisterback to summary
private Queryable determineAppropriateOwnerPersister(NonScalarReturn ownerDescriptor)
getCollectionAliasesback to summary
protected CollectionAliases[] getCollectionAliases()

Implements abstract org.hibernate.loader.Loader.getCollectionAliases.

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.

Doc from org.hibernate.loader.Loader.getCollectionPersisters.

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

Annotations
@Override
getEntityAliasesback to summary
protected EntityAliases[] getEntityAliases()

Implements abstract org.hibernate.loader.Loader.getEntityAliases.

Doc from org.hibernate.loader.Loader.getEntityAliases.

Get the result set descriptor

Annotations
@Override
getEntityPersistersback to summary
protected 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 options specified dynamically via the Query interface

Annotations
@Override
getOwnersback to summary
protected int[] getOwners()

Overrides org.hibernate.loader.Loader.getOwners.

Doc from 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"). The indexes contained here are relative to the result of getEntityPersisters.

Returns:int[]

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
getQuerySpacesback to summary
public Set<E> getQuerySpaces()
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
@Override
@SuppressWarnings:unchecked
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
getReturnAliasesForTransformerback to summary
private String[] getReturnAliasesForTransformer()
getSQLStringback to summary
public String getSQLString()

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

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

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

Returns:String

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

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

Overrides org.hibernate.loader.Loader.includeInResultRow.

Annotations
@Override
listback to summary
public List<E> list(SharedSessionContractImplementor session, QueryParameters queryParameters) throws HibernateException
putResultInQueryCacheback to summary
protected void putResultInQueryCache(final SharedSessionContractImplementor session, final QueryParameters queryParameters, final Type[] resultTypes, final QueryResultsCache queryCache, final QueryKey key, final List<E> result)

Overrides org.hibernate.loader.Loader.putResultInQueryCache.

Deprecated

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

resultTypes can be overridden by autoDiscoverTypes(ResultSet), *after* list(SharedSessionContractImplementor, QueryParameters) has already been called. It's a bit of a chicken-and-the-egg issue since autoDiscoverTypes(ResultSet) needs the ResultSet.

As a hacky workaround, overridden here to provide the resultTypes. see HHH-3051

Annotations
@Override
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
validateAliasback to summary
protected void validateAlias(String alias)
Annotations
@SuppressWarnings:UnusedParameters
validateAliasesback to summary
private void validateAliases(List<String> aliases)