public class CustomLoader extends Loader
Extension point for loaders which use a SQL result set with "unexpected" column aliases.
Loader.SqlStatementWrapperDEBUG_ENABLED, LOG, SELECT, SELECT_DISTINCT| Constructor and Description |
|---|
CustomLoader(CustomQuery customQuery,
SessionFactoryImplementor factory) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
applyLocks(String sql,
QueryParameters parameters,
Dialect dialect,
List<AfterLoadAction> afterLoadActions)
Append <tt>FOR UPDATE OF</tt> clause, if necessary.
|
protected void |
autoDiscoverTypes(ResultSet rs) |
protected int |
bindParameterValues(PreparedStatement statement,
QueryParameters queryParameters,
int startIndex,
SharedSessionContractImplementor session)
Bind all parameter values into the prepared statement in preparation
for execution.
|
protected CollectionAliases[] |
getCollectionAliases() |
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.
|
protected CollectionPersister[] |
getCollectionPersisters()
An (optional) persister for a collection to be initialized; only
collection loaders return a non-null value
|
protected EntityAliases[] |
getEntityAliases()
Get the result set descriptor
|
protected Loadable[] |
getEntityPersisters()
An array of persisters of entity classes contained in each row of results;
implemented by all subclasses
|
protected LockMode[] |
getLockModes(LockOptions lockOptions)
What lock options does this load entities with?
|
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").
|
protected String |
getQueryIdentifier()
Identifies the query for statistics reporting, if null,
no statistics will be reported
|
Set |
getQuerySpaces() |
protected Object |
getResultColumnOrRow(Object[] row,
ResultTransformer transformer,
ResultSet rs,
SharedSessionContractImplementor session)
Get the actual object that is returned in the user-visible result list.
|
protected List |
getResultList(List results,
ResultTransformer resultTransformer) |
protected Object[] |
getResultRow(Object[] row,
ResultSet rs,
SharedSessionContractImplementor session) |
protected String[] |
getResultRowAliases()
Returns the aliases that corresponding to a result row.
|
String |
getSQLString()
The SQL query string to be called; implemented by all subclasses
|
protected boolean[] |
includeInResultRow() |
List |
list(SharedSessionContractImplementor session,
QueryParameters queryParameters) |
protected void |
putResultInQueryCache(SharedSessionContractImplementor session,
QueryParameters queryParameters,
Type[] resultTypes,
QueryResultsCache queryCache,
QueryKey key,
List result)
resultTypes can be overridden by autoDiscoverTypes(ResultSet),
after list(SharedSessionContractImplementor, QueryParameters) has already been called. |
protected ResultTransformer |
resolveResultTransformer(ResultTransformer resultTransformer)
Determine the actual ResultTransformer that will be used to
transform query results.
|
ScrollableResultsImplementor |
scroll(QueryParameters queryParameters,
SharedSessionContractImplementor session) |
protected void |
validateAlias(String alias) |
applyPostLoadLocks, areResultSetRowsTransformedImmediately, bindNamedParameters, bindPositionalParameters, checkScrollability, determineFollowOnLockMode, doList, doQueryAndInitializeNonLazyCollections, doQueryAndInitializeNonLazyCollections, executeQueryStatement, executeQueryStatement, extractKeysFromResultSet, getAliases, getCompositeKeyManyToOneTargetIndices, getEntityEagerPropertyFetches, getFactory, getLimitHandler, getNamedParameterLocs, getOwnerAssociationTypes, getResultSet, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, isSubselectLoadingEnabled, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, needsFetchingScroll, postInstantiate, prepareQueryStatement, preprocessSQL, processDistinctKeyword, processResultSet, scroll, shouldUseFollowOnLocking, toString, upgradeLockspublic CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory)
protected String getQueryIdentifier()
LoaderIdentifies the query for statistics reporting, if null, no statistics will be reported
getQueryIdentifier in class Loaderpublic String getSQLString()
LoaderThe SQL query string to be called; implemented by all subclasses
getSQLString in class LoaderResultSet.public Set getQuerySpaces()
protected LockMode[] getLockModes(LockOptions lockOptions)
LoaderWhat lock options does this load entities with?
getLockModes in class LoaderlockOptions - a collection of lock options specified dynamically via the Query interfaceprotected Loadable[] getEntityPersisters()
LoaderAn array of persisters of entity classes contained in each row of results; implemented by all subclasses
getEntityPersisters in class Loaderprotected CollectionPersister[] getCollectionPersisters()
LoaderAn (optional) persister for a collection to be initialized; only collection loaders return a non-null value
getCollectionPersisters in class Loaderprotected int[] getCollectionOwners()
LoaderGet 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.
getCollectionOwners in class Loaderprotected int[] getOwners()
LoaderAn 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
Loader.getEntityPersisters().
public List list(SharedSessionContractImplementor session, QueryParameters queryParameters) throws HibernateException
HibernateExceptionprotected String applyLocks(String sql, QueryParameters parameters, Dialect dialect, List<AfterLoadAction> afterLoadActions) throws QueryException
LoaderAppend <tt>FOR UPDATE OF</tt> clause, if necessary. This empty superclass implementation merely returns its first argument.
applyLocks in class LoaderQueryExceptionpublic ScrollableResultsImplementor scroll(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException
HibernateExceptionprotected String[] getResultRowAliases()
LoaderReturns the aliases that corresponding to a result row.
getResultRowAliases in class Loaderprotected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
LoaderDetermine the actual ResultTransformer that will be used to transform query results.
resolveResultTransformer in class LoaderresultTransformer - the specified result transformerprotected boolean[] includeInResultRow()
includeInResultRow in class Loaderprotected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException
LoaderGet 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.
getResultColumnOrRow in class LoaderSQLExceptionHibernateExceptionprotected Object[] getResultRow(Object[] row, ResultSet rs, SharedSessionContractImplementor session) throws SQLException, HibernateException
getResultRow in class LoaderSQLExceptionHibernateExceptionprotected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException
getResultList in class LoaderQueryExceptionprotected EntityAliases[] getEntityAliases()
LoaderGet the result set descriptor
getEntityAliases in class Loaderprotected CollectionAliases[] getCollectionAliases()
getCollectionAliases in class Loaderprotected int bindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session) throws SQLException
LoaderBind all parameter values into the prepared statement in preparation for execution.
bindParameterValues in class Loaderstatement - The JDBC prepared statementqueryParameters - The encapsulation of the parameter values to be bound.startIndex - The position from which to start binding parameter values.session - The originating session.SQLException - Indicates problems performing the binding.protected void autoDiscoverTypes(ResultSet rs)
autoDiscoverTypes in class Loaderprotected void validateAlias(String alias)
protected void putResultInQueryCache(SharedSessionContractImplementor session, QueryParameters queryParameters, Type[] resultTypes, QueryResultsCache queryCache, QueryKey key, List result)
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.
<p/>
As a hacky workaround, overriden here to provide the resultTypes.
see HHH-3051
putResultInQueryCache in class LoaderCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.