public class

QueryLoader

extends BasicLoader
java.lang.Object
   ↳ org.hibernate.loader.Loader
     ↳ org.hibernate.loader.BasicLoader
       ↳ org.hibernate.loader.hql.QueryLoader

Class Overview

A delegate that implements the Loader part of QueryTranslator.

Summary

[Expand]
Inherited Fields
From class org.hibernate.loader.BasicLoader
Public Constructors
QueryLoader(QueryTranslatorImpl queryTranslator, SessionFactoryImplementor factory, SelectClause selectClause)
Creates a new Loader implementation.
Public Methods
String[] getAliases()
Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading
String[] getCollectionSuffixes()
Loadable[] getEntityPersisters()
An array of persisters of entity classes contained in each row of results; implemented by all subclasses
int[] getNamedParameterLocs(String name)
Returns the locations of all occurrences of the named parameter.
String[] getSqlAliasSuffixes()
String[] getSuffixes()
Iterator iterate(QueryParameters queryParameters, EventSource session)
List list(SessionImplementor session, QueryParameters queryParameters)
ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
final void validateScrollability()
Protected Methods
String applyLocks(String sql, LockOptions lockOptions, Dialect dialect)
Append FOR UPDATE OF clause, if necessary.
void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session)
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.
int[] getCollectionOwners()
Get the index of the entity that owns the collection, or -1 if there is no owner in the query results (ie.
CollectionPersister[] getCollectionPersisters()
An (optional) persister for a collection to be initialized; only collection loaders return a non-null value
boolean[] getEntityEagerPropertyFetches()
An array indicating whether the entities have eager property fetching enabled.
LockMode[] getLockModes(LockOptions lockOptions)
What lock options does this load entities with?
EntityType[] getOwnerAssociationTypes()
An array of the owner types corresponding to the getOwners() returns.
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")
String getQueryIdentifier()
Identifies the query for statistics reporting, if null, no statistics will be reported
Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)
Get the actual object that is returned in the user-visible result list.
List getResultList(List results, ResultTransformer resultTransformer)
String getSQLString()
The SQL query string to be called.
boolean isSubselectLoadingEnabled()
boolean needsFetchingScroll()
Does the result set to be scrolled contain collection fetches?
ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
Determine the actual ResultTransformer that will be used to transform query results.
boolean upgradeLocks()
Does this query return objects that might be already cached by the session, whose lock mode may need upgrading
[Expand]
Inherited Methods
From class org.hibernate.loader.BasicLoader
From class org.hibernate.loader.Loader
From class java.lang.Object

Public Constructors

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.

Public Methods

public String[] getAliases ()

Get the SQL table aliases of entities whose associations are subselect-loadable, returning null if this loader does not support subselect loading

public String[] getCollectionSuffixes ()

public Loadable[] getEntityPersisters ()

An array of persisters of entity classes contained in each row of results; implemented by all subclasses

Returns
  • The entity persisters.

public int[] getNamedParameterLocs (String name)

Returns the locations of all occurrences of the named parameter.

public String[] getSqlAliasSuffixes ()

public String[] getSuffixes ()

public Iterator iterate (QueryParameters queryParameters, EventSource session)

public List list (SessionImplementor session, QueryParameters queryParameters)

public ScrollableResults scroll (QueryParameters queryParameters, SessionImplementor session)

public final void validateScrollability ()

Protected Methods

protected String applyLocks (String sql, LockOptions lockOptions, Dialect dialect)

Append FOR UPDATE OF clause, if necessary. This empty superclass implementation merely returns its first argument.

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.

Parameters
statement The JDBC prepared statement
queryParameters 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.

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. in the case of a collection initializer) or no collection.

protected CollectionPersister[] getCollectionPersisters ()

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

protected boolean[] getEntityEagerPropertyFetches ()

An array indicating whether the entities have eager property fetching enabled.

Returns
  • Eager property fetching indicators.

protected LockMode[] getLockModes (LockOptions lockOptions)

What lock options does this load entities with?

Parameters
lockOptions a collection of lock modes specified dynamically via the Query interface

protected EntityType[] getOwnerAssociationTypes ()

An array of the owner types corresponding to the getOwners() returns. Indices indicating no owner would be null here.

Returns
  • The types for the owners.

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")

Returns
  • The owner indicators (see discussion above).

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. This empty implementation merely returns its first argument. This is overridden by some subclasses.

protected List getResultList (List results, ResultTransformer resultTransformer)

protected String getSQLString ()

The SQL query string to be called.

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

protected boolean isSubselectLoadingEnabled ()

protected boolean needsFetchingScroll ()

Does the result set to be scrolled contain collection fetches?

Returns
  • True if it does, and thus needs the special fetching scroll functionality; false otherwise.

protected ResultTransformer resolveResultTransformer (ResultTransformer resultTransformer)

Determine the actual ResultTransformer that will be used to transform query results.

Parameters
resultTransformer the specified result transformer
Returns
  • the actual result transformer

protected boolean upgradeLocks ()

Does this query return objects that might be already cached by the session, whose lock mode may need upgrading