Package org.hibernate.loader.hql
Class QueryLoader
- java.lang.Object
-
- org.hibernate.loader.Loader
-
- org.hibernate.loader.BasicLoader
-
- org.hibernate.loader.hql.QueryLoader
-
public class QueryLoader extends BasicLoader
A delegate that implements the Loader part of QueryTranslator.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hibernate.loader.Loader
Loader.SqlStatementWrapper
-
-
Field Summary
-
Fields inherited from class org.hibernate.loader.BasicLoader
NO_SUFFIX
-
Fields inherited from class org.hibernate.loader.Loader
DEBUG_ENABLED, LOG, SELECT, SELECT_DISTINCT
-
-
Constructor Summary
Constructors Constructor Description QueryLoader(org.hibernate.hql.internal.ast.QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, org.hibernate.hql.internal.ast.tree.SelectClause selectClause)
Creates a new Loader implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
applyLocks(java.lang.String sql, QueryParameters parameters, Dialect dialect, java.util.List<AfterLoadAction> afterLoadActions)
Append FOR UPDATE OF clause, if necessary.protected void
applyPostLoadLocks(java.lang.Object[] row, LockMode[] lockModesArray, SharedSessionContractImplementor session)
protected int
bindParameterValues(java.sql.PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session)
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.org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression
getAggregatedSelectExpression()
java.lang.String[]
getAliases()
Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loadingprotected 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 valuejava.lang.String[]
getCollectionSuffixes()
protected boolean[]
getEntityEagerPropertyFetches()
An array indicating whether the entities have eager property fetching enabled.Loadable[]
getEntityPersisters()
An array of persisters of entity classes contained in each row of results; implemented by all subclassesprotected LockMode[]
getLockModes(LockOptions lockOptions)
What lock options does this load entities with?int[]
getNamedParameterLocs(java.lang.String name)
Returns the locations of all occurrences of the named parameter.protected EntityType[]
getOwnerAssociationTypes()
An array of the owner types corresponding to theLoader.getOwners()
returns.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 java.lang.String
getQueryIdentifier()
Identifies the query for statistics reporting, if null, no statistics will be reportedprotected java.lang.Object
getResultColumnOrRow(java.lang.Object[] row, ResultTransformer transformer, java.sql.ResultSet rs, SharedSessionContractImplementor session)
Get the actual object that is returned in the user-visible result list.protected java.util.List
getResultList(java.util.List results, ResultTransformer resultTransformer)
protected java.lang.Object[]
getResultRow(java.lang.Object[] row, java.sql.ResultSet rs, SharedSessionContractImplementor session)
protected java.lang.String[]
getResultRowAliases()
Returns the aliases that corresponding to a result row.java.lang.String[]
getSqlAliasSuffixes()
java.lang.String
getSQLString()
The SQL query string to be called.java.lang.String[]
getSuffixes()
protected boolean[]
includeInResultRow()
protected boolean
isSubselectLoadingEnabled()
java.util.Iterator
iterate(QueryParameters queryParameters, EventSource session)
java.util.List
list(SharedSessionContractImplementor session, QueryParameters queryParameters)
protected boolean
needsFetchingScroll()
Does the result set to be scrolled contain collection fetches?protected ResultTransformer
resolveResultTransformer(ResultTransformer resultTransformer)
Determine the actual ResultTransformer that will be used to transform query results.ScrollableResultsImplementor
scroll(QueryParameters queryParameters, SharedSessionContractImplementor session)
protected boolean
upgradeLocks()
Does this query return objects that might be already cached by the session, whose lock mode may need upgradingvoid
validateScrollability()
-
Methods inherited from class org.hibernate.loader.BasicLoader
generateSuffixes, generateSuffixes, getCollectionAliases, getEntityAliases, postInstantiate
-
Methods inherited from class org.hibernate.loader.Loader
areResultSetRowsTransformedImmediately, autoDiscoverTypes, bindNamedParameters, bindPositionalParameters, checkScrollability, determineFollowOnLockMode, doList, doQueryAndInitializeNonLazyCollections, doQueryAndInitializeNonLazyCollections, executeQueryStatement, executeQueryStatement, extractKeysFromResultSet, getCompositeKeyManyToOneTargetIndices, getFactory, getLimitHandler, getResultSet, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, prepareQueryStatement, preprocessSQL, processDistinctKeyword, processResultSet, putResultInQueryCache, scroll, shouldUseFollowOnLocking, toString
-
-
-
-
Constructor Detail
-
QueryLoader
public QueryLoader(org.hibernate.hql.internal.ast.QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, org.hibernate.hql.internal.ast.tree.SelectClause selectClause)
Creates a new Loader implementation.- Parameters:
queryTranslator
- The query translator that is the delegator.factory
- The factory from which this loader is being created.selectClause
- The AST representing the select clause for loading.
-
-
Method Detail
-
getAggregatedSelectExpression
public org.hibernate.hql.internal.ast.tree.AggregatedSelectExpression getAggregatedSelectExpression()
-
validateScrollability
public final void validateScrollability() throws HibernateException
- Throws:
HibernateException
-
needsFetchingScroll
protected boolean needsFetchingScroll()
Description copied from class:Loader
Does the result set to be scrolled contain collection fetches?- Overrides:
needsFetchingScroll
in classLoader
- Returns:
- True if it does, and thus needs the special fetching scroll functionality; false otherwise.
-
getEntityPersisters
public Loadable[] getEntityPersisters()
Description copied from class:Loader
An array of persisters of entity classes contained in each row of results; implemented by all subclasses- Specified by:
getEntityPersisters
in classLoader
- Returns:
- The entity persisters.
-
getAliases
public java.lang.String[] getAliases()
Description copied from class:Loader
Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading- Overrides:
getAliases
in classLoader
-
getSqlAliasSuffixes
public java.lang.String[] getSqlAliasSuffixes()
-
getSuffixes
public java.lang.String[] getSuffixes()
- Specified by:
getSuffixes
in classBasicLoader
-
getCollectionSuffixes
public java.lang.String[] getCollectionSuffixes()
- Specified by:
getCollectionSuffixes
in classBasicLoader
-
getQueryIdentifier
protected java.lang.String getQueryIdentifier()
Description copied from class:Loader
Identifies the query for statistics reporting, if null, no statistics will be reported- Overrides:
getQueryIdentifier
in classLoader
-
getSQLString
public java.lang.String getSQLString()
The SQL query string to be called.- Specified by:
getSQLString
in classLoader
- Returns:
- The sql command this loader should use to get its
ResultSet
.
-
getCollectionPersisters
protected CollectionPersister[] getCollectionPersisters()
An (optional) persister for a collection to be initialized; only collection loaders return a non-null value- Overrides:
getCollectionPersisters
in classLoader
-
getCollectionOwners
protected int[] getCollectionOwners()
Description copied from class:Loader
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.- Overrides:
getCollectionOwners
in classLoader
-
getEntityEagerPropertyFetches
protected boolean[] getEntityEagerPropertyFetches()
Description copied from class:Loader
An array indicating whether the entities have eager property fetching enabled.- Overrides:
getEntityEagerPropertyFetches
in classLoader
- Returns:
- Eager property fetching indicators.
-
getOwners
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")
-
getOwnerAssociationTypes
protected EntityType[] getOwnerAssociationTypes()
Description copied from class:Loader
An array of the owner types corresponding to theLoader.getOwners()
returns. Indices indicating no owner would be null here.- Overrides:
getOwnerAssociationTypes
in classLoader
- Returns:
- The types for the owners.
-
isSubselectLoadingEnabled
protected boolean isSubselectLoadingEnabled()
- Overrides:
isSubselectLoadingEnabled
in classLoader
-
getLockModes
protected LockMode[] getLockModes(LockOptions lockOptions)
Description copied from class:Loader
What lock options does this load entities with?- Specified by:
getLockModes
in classLoader
- Parameters:
lockOptions
- a collection of lock modes specified dynamically via the Query interface
-
applyLocks
protected java.lang.String applyLocks(java.lang.String sql, QueryParameters parameters, Dialect dialect, java.util.List<AfterLoadAction> afterLoadActions) throws QueryException
Description copied from class:Loader
Append FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.- Overrides:
applyLocks
in classLoader
- Throws:
QueryException
-
applyPostLoadLocks
protected void applyPostLoadLocks(java.lang.Object[] row, LockMode[] lockModesArray, SharedSessionContractImplementor session)
- Overrides:
applyPostLoadLocks
in classLoader
-
upgradeLocks
protected boolean upgradeLocks()
Description copied from class:Loader
Does this query return objects that might be already cached by the session, whose lock mode may need upgrading- Overrides:
upgradeLocks
in classLoader
-
getResultRowAliases
protected java.lang.String[] getResultRowAliases()
Description copied from class:Loader
Returns the aliases that corresponding to a result row.- Overrides:
getResultRowAliases
in classLoader
- Returns:
- Returns the aliases that corresponding to a result row.
-
resolveResultTransformer
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
Description copied from class:Loader
Determine the actual ResultTransformer that will be used to transform query results.- Overrides:
resolveResultTransformer
in classLoader
- Parameters:
resultTransformer
- the specified result transformer- Returns:
- the actual result transformer
-
includeInResultRow
protected boolean[] includeInResultRow()
- Overrides:
includeInResultRow
in classLoader
-
getResultColumnOrRow
protected java.lang.Object getResultColumnOrRow(java.lang.Object[] row, ResultTransformer transformer, java.sql.ResultSet rs, SharedSessionContractImplementor session) throws java.sql.SQLException, HibernateException
Description copied from class:Loader
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.- Overrides:
getResultColumnOrRow
in classLoader
- Throws:
java.sql.SQLException
HibernateException
-
getResultRow
protected java.lang.Object[] getResultRow(java.lang.Object[] row, java.sql.ResultSet rs, SharedSessionContractImplementor session) throws java.sql.SQLException, HibernateException
- Overrides:
getResultRow
in classLoader
- Throws:
java.sql.SQLException
HibernateException
-
getResultList
protected java.util.List getResultList(java.util.List results, ResultTransformer resultTransformer) throws QueryException
- Overrides:
getResultList
in classLoader
- Throws:
QueryException
-
list
public java.util.List list(SharedSessionContractImplementor session, QueryParameters queryParameters) throws HibernateException
- Throws:
HibernateException
-
iterate
public java.util.Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException
- Throws:
HibernateException
-
scroll
public ScrollableResultsImplementor scroll(QueryParameters queryParameters, SharedSessionContractImplementor session) throws HibernateException
- Throws:
HibernateException
-
getNamedParameterLocs
public int[] getNamedParameterLocs(java.lang.String name) throws QueryException
Returns the locations of all occurrences of the named parameter.- Overrides:
getNamedParameterLocs
in classLoader
- Throws:
QueryException
-
bindParameterValues
protected int bindParameterValues(java.sql.PreparedStatement statement, QueryParameters queryParameters, int startIndex, SharedSessionContractImplementor session) throws java.sql.SQLException
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.- Overrides:
bindParameterValues
in classLoader
- Parameters:
queryParameters
- The encapsulation of the parameter values to be bound.startIndex
- The position from which to start binding parameter values.session
- The originating session.statement
- The JDBC prepared statement- Returns:
- The number of JDBC bind positions actually bound during this method execution.
- Throws:
java.sql.SQLException
- Indicates problems performing the binding.
-
-