org.hibernate.loader.custom

Class CustomLoader


public class CustomLoader
extends Loader

Extension point for loaders which use a SQL result set with "unexpected" column aliases.
Authors:
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(Map lockModesMap)
What lock mode 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)
ScrollableResults
scroll(QueryParameters queryParameters, SessionImplementor session)

Methods inherited from class org.hibernate.loader.Loader

applyLocks, autoDiscoverTypes, bindNamedParameters, bindParameterValues, bindPositionalParameters, checkScrollability, doList, getAliases, getCollectionAliases, getCollectionOwners, getCollectionPersisters, getEntityAliases, getEntityEagerPropertyFetches, getEntityPersisters, getFactory, getLockModes, getNamedParameterLocs, getOwnerAssociationTypes, getOwners, getQueryIdentifier, getResultColumnOrRow, getResultList, getResultSet, getSQLString, hasSubselectLoadableCollections, isSingleRowLoader, isSubselectLoadingEnabled, list, loadCollection, loadCollectionBatch, loadCollectionSubselect, loadEntity, loadEntity, loadEntityBatch, loadSequentialRowsForward, loadSequentialRowsReverse, loadSingleRow, needsFetchingScroll, postInstantiate, prepareQueryStatement, preprocessSQL, scroll, toString, upgradeLocks

Constructor Details

CustomLoader

public CustomLoader(CustomQuery customQuery,
                    SessionFactoryImplementor factory)

Method Details

autoDiscoverTypes

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

getCollectionAliases

protected CollectionAliases[] getCollectionAliases()
Overrides:
getCollectionAliases in interface Loader

getCollectionOwners

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.
Overrides:
getCollectionOwners in interface Loader

getCollectionPersisters

protected CollectionPersister[] getCollectionPersisters()
An (optional) persister for a collection to be initialized; only collection loaders return a non-null value
Overrides:
getCollectionPersisters in interface Loader

getEntityAliases

protected EntityAliases[] getEntityAliases()
Get the result set descriptor
Overrides:
getEntityAliases in interface Loader

getEntityPersisters

protected Loadable[] getEntityPersisters()
An array of persisters of entity classes contained in each row of results; implemented by all subclasses
Overrides:
getEntityPersisters in interface Loader
Returns:
The entity persisters.

getLockModes

protected LockMode[] getLockModes(Map lockModesMap)
What lock mode does this load entities with?
Overrides:
getLockModes in interface Loader
Parameters:

getNamedParameterLocs

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

getOwners

protected int[] getOwners()
Overrides:
getOwners in interface Loader
Returns:
The owner indicators (see discussion above).

getQueryIdentifier

protected String getQueryIdentifier()
Identifies the query for statistics reporting, if null, no statistics will be reported
Overrides:
getQueryIdentifier in interface Loader

getQuerySpaces

public Set getQuerySpaces()

getResultColumnOrRow

protected Object getResultColumnOrRow(Object[] row,
                                      ResultTransformer transformer,
                                      ResultSet rs,
                                      SessionImplementor session)
            throws SQLException,
                   HibernateException
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 interface Loader

getResultList

protected List getResultList(List results,
                             ResultTransformer resultTransformer)
            throws QueryException
Overrides:
getResultList in interface Loader

getSQLString

protected String getSQLString()
The SQL query string to be called; implemented by all subclasses
Overrides:
getSQLString in interface Loader
Returns:
The sql command this loader should use to get its ResultSet.

list

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

scroll

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