org.hibernate.loader.custom
Class CustomLoader

java.lang.Object
  extended by org.hibernate.loader.Loader
      extended by org.hibernate.loader.custom.CustomLoader

public class CustomLoader
extends Loader

Extension point for loaders which use a SQL result set with "unexpected" column aliases.

Author:
Gavin King, Steve Ebersole

Nested Class Summary
 class CustomLoader.NonScalarResultColumnProcessor
           
 class CustomLoader.ResultRowProcessor
           
 class CustomLoader.ScalarResultColumnProcessor
           
 
Constructor Summary
CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory)
           
 
Method Summary
protected  void autoDiscoverTypes(ResultSet rs)
           
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?
 int[] getNamedParameterLocs(String name)
           
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, SessionImplementor session)
          Get the actual object that is returned in the user-visible result list.
protected  List getResultList(List results, ResultTransformer resultTransformer)
           
protected  String getSQLString()
          The SQL query string to be called; implemented by all subclasses
 List list(SessionImplementor session, QueryParameters queryParameters)
           
protected  ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)
          Determine the actual ResultTransformer that will be used to transform query results.
 ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
           
 
Methods inherited from class org.hibernate.loader.Loader
applyLocks, applyPostLoadLocks, areResultSetRowsTransformedImmediately, bindNamedParameters, bindParameterValues, bindPositionalParameters, checkScrollability, doList, getAliases, getEntityEagerPropertyFetches, getFactory, getOwnerAssociationTypes, getResultSet, hasSubselectLoadableCollections, isSingleRowLoader, isSubselectLoadingEnabled, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, needsFetchingScroll, postInstantiate, prepareQueryStatement, preprocessSQL, scroll, toString, upgradeLocks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CustomLoader

public CustomLoader(CustomQuery customQuery,
                    SessionFactoryImplementor factory)
Method Detail

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()
Description copied from class: Loader
The SQL query string to be called; implemented by all subclasses

Specified by:
getSQLString in class Loader
Returns:
The sql command this loader should use to get its ResultSet.

getQuerySpaces

public Set getQuerySpaces()

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 options specified dynamically via the Query interface

getEntityPersisters

protected 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.

getCollectionPersisters

protected CollectionPersister[] getCollectionPersisters()
Description copied from class: Loader
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

getOwners

protected int[] getOwners()
Description copied from class: Loader
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"). The indexes contained here are relative to the result of Loader.getEntityPersisters().

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

list

public List list(SessionImplementor session,
                 QueryParameters queryParameters)
          throws HibernateException
Throws:
HibernateException

scroll

public ScrollableResults scroll(QueryParameters queryParameters,
                                SessionImplementor session)
                         throws HibernateException
Throws:
HibernateException

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

getEntityAliases

protected EntityAliases[] getEntityAliases()
Description copied from class: Loader
Get the result set descriptor

Specified by:
getEntityAliases in class Loader

getCollectionAliases

protected CollectionAliases[] getCollectionAliases()
Specified by:
getCollectionAliases in class Loader

getNamedParameterLocs

public int[] getNamedParameterLocs(String name)
                            throws QueryException
Overrides:
getNamedParameterLocs in class Loader
Throws:
QueryException

autoDiscoverTypes

protected void autoDiscoverTypes(ResultSet rs)
Overrides:
autoDiscoverTypes in class Loader


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