Package org.hibernate.loader.hql
Class QueryLoader
java.lang.Object
org.hibernate.loader.Loader
org.hibernate.loader.BasicLoader
org.hibernate.loader.hql.QueryLoader
A delegate that implements the Loader part of QueryTranslator.
-
Field Summary
Fields inherited from class org.hibernate.loader.BasicLoader
NO_SUFFIX -
Constructor Summary
ConstructorsConstructorDescriptionQueryLoader(QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, SelectClause selectClause) Creates a new Loader implementation. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringapplyLocks(String sql, LockOptions lockOptions, Dialect dialect) Append FOR UPDATE OF clause, if necessary.protected voidapplyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session) protected intbindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SessionImplementor 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 explciitly here through the ParameterSpecification interface.String[]Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loadingprotected int[]Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie.protected CollectionPersister[]An (optional) persister for a collection to be initialized; only collection loaders return a non-null valueString[]protected boolean[]An array indicating whether the entities have eager property fetching enabled.Loadable[]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(String name) Returns the locations of all occurrences of the named parameter.protected EntityType[]An array of the owner types corresponding to theLoader.getOwners()returns.protected int[]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 StringIdentifies the query for statistics reporting, if null, no statistics will be reportedprotected ObjectgetResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session) Get the actual object that is returned in the user-visible result list.protected ListgetResultList(List results, ResultTransformer resultTransformer) String[]protected StringThe SQL query string to be called.String[]protected booleaniterate(QueryParameters queryParameters, EventSource session) list(SessionImplementor session, QueryParameters queryParameters) protected booleanDoes the result set to be scrolled contain collection fetches?protected ResultTransformerresolveResultTransformer(ResultTransformer resultTransformer) Determine the actual ResultTransformer that will be used to transform query results.scroll(QueryParameters queryParameters, SessionImplementor session) protected booleanDoes this query return objects that might be already cached by the session, whose lock mode may need upgradingfinal voidMethods inherited from class org.hibernate.loader.BasicLoader
generateSuffixes, generateSuffixes, getCollectionAliases, getEntityAliases, postInstantiateMethods inherited from class org.hibernate.loader.Loader
areResultSetRowsTransformedImmediately, autoDiscoverTypes, bindNamedParameters, bindPositionalParameters, checkScrollability, doList, extractKeysFromResultSet, getCompositeKeyManyToOneTargetIndices, getFactory, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, prepareQueryStatement, preprocessSQL, scroll, toString
-
Constructor Details
-
QueryLoader
public QueryLoader(QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, 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 Details
-
getAggregatedSelectExpression
-
validateScrollability
- Throws:
HibernateException
-
needsFetchingScroll
protected boolean needsFetchingScroll()Description copied from class:LoaderDoes the result set to be scrolled contain collection fetches?- Overrides:
needsFetchingScrollin classLoader- Returns:
- True if it does, and thus needs the special fetching scroll functionality; false otherwise.
-
getEntityPersisters
Description copied from class:LoaderAn array of persisters of entity classes contained in each row of results; implemented by all subclasses- Specified by:
getEntityPersistersin classLoader- Returns:
- The entity persisters.
-
getAliases
Description copied from class:LoaderGet the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading- Overrides:
getAliasesin classLoader
-
getSqlAliasSuffixes
-
getSuffixes
- Specified by:
getSuffixesin classBasicLoader
-
getCollectionSuffixes
- Specified by:
getCollectionSuffixesin classBasicLoader
-
getQueryIdentifier
Description copied from class:LoaderIdentifies the query for statistics reporting, if null, no statistics will be reported- Overrides:
getQueryIdentifierin classLoader
-
getSQLString
The SQL query string to be called.- Specified by:
getSQLStringin classLoader- Returns:
- The sql command this loader should use to get its
ResultSet.
-
getCollectionPersisters
An (optional) persister for a collection to be initialized; only collection loaders return a non-null value- Overrides:
getCollectionPersistersin classLoader
-
getCollectionOwners
protected int[] getCollectionOwners()Description copied from class: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.- Overrides:
getCollectionOwnersin classLoader
-
getEntityEagerPropertyFetches
protected boolean[] getEntityEagerPropertyFetches()Description copied from class:LoaderAn array indicating whether the entities have eager property fetching enabled.- Overrides:
getEntityEagerPropertyFetchesin 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
Description copied from class:LoaderAn array of the owner types corresponding to theLoader.getOwners()returns. Indices indicating no owner would be null here.- Overrides:
getOwnerAssociationTypesin classLoader- Returns:
- The types for the owners.
-
isSubselectLoadingEnabled
protected boolean isSubselectLoadingEnabled()- Overrides:
isSubselectLoadingEnabledin classLoader
-
getLockModes
Description copied from class:LoaderWhat lock options does this load entities with?- Specified by:
getLockModesin classLoader- Parameters:
lockOptions- a collection of lock modes specified dynamically via the Query interface
-
applyLocks
protected String applyLocks(String sql, LockOptions lockOptions, Dialect dialect) throws QueryException Description copied from class:LoaderAppend FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.- Overrides:
applyLocksin classLoader- Throws:
QueryException
-
applyPostLoadLocks
protected void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session) - Overrides:
applyPostLoadLocksin classLoader
-
upgradeLocks
protected boolean upgradeLocks()Description copied from class:LoaderDoes this query return objects that might be already cached by the session, whose lock mode may need upgrading- Overrides:
upgradeLocksin classLoader
-
resolveResultTransformer
Description copied from class:LoaderDetermine the actual ResultTransformer that will be used to transform query results.- Overrides:
resolveResultTransformerin classLoader- Parameters:
resultTransformer- the specified result transformer- Returns:
- the actual result transformer
-
getResultColumnOrRow
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException Description copied from class: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.- Overrides:
getResultColumnOrRowin classLoader- Throws:
SQLExceptionHibernateException
-
getResultList
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException - Overrides:
getResultListin classLoader- Throws:
QueryException
-
list
public List list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException - Throws:
HibernateException
-
iterate
public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException - Throws:
HibernateException
-
scroll
public ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session) throws HibernateException - Throws:
HibernateException
-
getNamedParameterLocs
Returns the locations of all occurrences of the named parameter.- Overrides:
getNamedParameterLocsin classLoader- Throws:
QueryException
-
bindParameterValues
protected int bindParameterValues(PreparedStatement statement, QueryParameters queryParameters, int startIndex, SessionImplementor session) throws 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 explciitly here through the ParameterSpecification interface.- Overrides:
bindParameterValuesin classLoader- Parameters:
statement- 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.- Returns:
- The number of JDBC bind positions actually bound during this method execution.
- Throws:
SQLException- Indicates problems performing the binding.
-