org.hibernate.loader.hql
Class QueryLoader

java.lang.Object
  extended by org.hibernate.loader.Loader
      extended by org.hibernate.loader.BasicLoader
          extended by org.hibernate.loader.hql.QueryLoader

public class QueryLoader
extends BasicLoader

A delegate that implements the Loader part of QueryTranslator.

Author:
josh

Field Summary
 
Fields inherited from class org.hibernate.loader.BasicLoader
NO_SUFFIX
 
Constructor Summary
QueryLoader(QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, SelectClause selectClause)
          Creates a new Loader implementation.
 
Method Summary
protected  String applyLocks(String sql, LockOptions lockOptions, Dialect dialect)
          Append FOR UPDATE OF clause, if necessary.
protected  void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session)
           
protected  int bindParameterValues(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.
 AggregatedSelectExpression getAggregatedSelectExpression()
           
 String[] 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()
          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
 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 subclasses
protected  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[] getOwnerAssociationTypes()
          An array of the owner types corresponding to the Loader.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  String getQueryIdentifier()
          Identifies the query for statistics reporting, if null, no statistics will be reported
protected  Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
          Get the actual object that is returned in the user-visible result list.
protected  List getResultList(List results, ResultTransformer resultTransformer)
           
 String[] getSqlAliasSuffixes()
           
protected  String getSQLString()
          The SQL query string to be called.
 String[] getSuffixes()
           
protected  boolean isSubselectLoadingEnabled()
           
 Iterator iterate(QueryParameters queryParameters, EventSource session)
           
 List list(SessionImplementor 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.
 ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
           
protected  boolean upgradeLocks()
          Does this query return objects that might be already cached by the session, whose lock mode may need upgrading
 void 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, doList, extractKeysFromResultSet, getCompositeKeyManyToOneTargetIndices, getFactory, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, prepareQueryStatement, preprocessSQL, scroll, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

getAggregatedSelectExpression

public 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 class Loader
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 class Loader
Returns:
The entity persisters.

getAliases

public 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 class Loader

getSqlAliasSuffixes

public String[] getSqlAliasSuffixes()

getSuffixes

public String[] getSuffixes()
Specified by:
getSuffixes in class BasicLoader

getCollectionSuffixes

public String[] getCollectionSuffixes()
Specified by:
getCollectionSuffixes in class BasicLoader

getQueryIdentifier

protected String getQueryIdentifier()
Description copied from class: Loader
Identifies the query for statistics reporting, if null, no statistics will be reported

Overrides:
getQueryIdentifier in class Loader

getSQLString

protected String getSQLString()
The SQL query string to be called.

Specified by:
getSQLString in class Loader
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 class Loader

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 class Loader

getEntityEagerPropertyFetches

protected boolean[] getEntityEagerPropertyFetches()
Description copied from class: Loader
An array indicating whether the entities have eager property fetching enabled.

Overrides:
getEntityEagerPropertyFetches in class Loader
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")

Overrides:
getOwners in class Loader
Returns:
The owner indicators (see discussion above).

getOwnerAssociationTypes

protected EntityType[] getOwnerAssociationTypes()
Description copied from class: Loader
An array of the owner types corresponding to the Loader.getOwners() returns. Indices indicating no owner would be null here.

Overrides:
getOwnerAssociationTypes in class Loader
Returns:
The types for the owners.

isSubselectLoadingEnabled

protected boolean isSubselectLoadingEnabled()
Overrides:
isSubselectLoadingEnabled in class Loader

getLockModes

protected LockMode[] getLockModes(LockOptions lockOptions)
Description copied from class: Loader
What lock options does this load entities with?

Specified by:
getLockModes in class Loader
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: Loader
Append FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.

Overrides:
applyLocks in class Loader
Throws:
QueryException

applyPostLoadLocks

protected void applyPostLoadLocks(Object[] row,
                                  LockMode[] lockModesArray,
                                  SessionImplementor session)
Overrides:
applyPostLoadLocks in class Loader

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 class Loader

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 class Loader
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: 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 class Loader
Throws:
SQLException
HibernateException

getResultList

protected List getResultList(List results,
                             ResultTransformer resultTransformer)
                      throws QueryException
Overrides:
getResultList in class Loader
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

public int[] getNamedParameterLocs(String name)
                            throws QueryException
Returns the locations of all occurrences of the named parameter.

Overrides:
getNamedParameterLocs in class Loader
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:
bindParameterValues in class Loader
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:
SQLException - Indicates problems performing the binding.


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.