Top Description Inners Fields Constructors Methods
org.hibernate.loader.custom

public Class CustomLoader

extends Loader
Class Inheritance
Imports
java.sql.ResultSet, .ResultSetMetaData, .SQLException, java.util.List, .Map, .Set, .ArrayList, .Iterator, .HashSet, org.hibernate.HibernateException, .LockMode, .QueryException, .ScrollableResults, .LockOptions, org.hibernate.engine.QueryParameters, .SessionFactoryImplementor, .SessionImplementor, org.hibernate.hql.HolderInstantiator, org.hibernate.loader.CollectionAliases, .EntityAliases, .Loader, org.hibernate.persister.collection.CollectionPersister, .QueryableCollection, org.hibernate.persister.entity.Loadable, .Queryable, org.hibernate.transform.ResultTransformer, org.hibernate.type.Type, .TypeFactory, .EntityType, .CollectionType, org.hibernate.util.ArrayHelper, .StringHelper

Extension point for loaders which use a SQL result set with "unexpected" column aliases.
Authors
Gavin King, Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public class
private static interface
public class
public class

Field Summary

Modifier and TypeField and Description
private final CollectionAliases[]
private final int[]
private final QueryableCollection[]
private final EntityAliases[]
private final Queryable[]
private final int[]
private final LockMode[]
private final Map<K, V>
private final Set<E>
private Type[]
private final CustomLoader.ResultRowProcessor
private final String
private String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
private Queryable
protected CollectionAliases[]
protected int[]
getCollectionOwners()

Overrides org.hibernate.loader.Loader.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()

Overrides org.hibernate.loader.Loader.getCollectionPersisters.

An (optional) persister for a collection to be initialized; only collection loaders return a non-null value
protected EntityAliases[]
getEntityAliases()

Implements abstract org.hibernate.loader.Loader.getEntityAliases.

Get the result set descriptor
protected Loadable[]
getEntityPersisters()

Implements abstract org.hibernate.loader.Loader.getEntityPersisters.

An array of persisters of entity classes contained in each row of results; implemented by all subclasses
private static HolderInstantiator
getHolderInstantiator(ResultTransformer resultTransformer, String[] queryReturnAliases)

protected LockMode[]
getLockModes(LockOptions
a collection of lock options specified dynamically via the Query interface
lockOptions
)

Implements abstract org.hibernate.loader.Loader.getLockModes.

What lock options does this load entities with?
public int[]
protected int[]
getOwners()

Overrides org.hibernate.loader.Loader.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()

Overrides org.hibernate.loader.Loader.getQueryIdentifier.

Identifies the query for statistics reporting, if null, no statistics will be reported
public Set<E>
protected Object
getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session)

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

Get the actual object that is returned in the user-visible result list.
protected List<E>
private String[]
protected String
getSQLString()

Implements abstract org.hibernate.loader.Loader.getSQLString.

The SQL query string to be called; implemented by all subclasses
public List<E>
list(SessionImplementor session, QueryParameters queryParameters)

protected ResultTransformer
resolveResultTransformer(ResultTransformer
the specified result transformer
resultTransformer
)

Overrides org.hibernate.loader.Loader.resolveResultTransformer.

Determine the actual ResultTransformer that will be used to transform query results.
public ScrollableResults
scroll(final QueryParameters queryParameters, final SessionImplementor session)

Inherited from org.hibernate.loader.Loader:
applyLocksapplyPostLoadLocksareResultSetRowsTransformedImmediatelybindNamedParametersbindParameterValuesbindPositionalParameterscheckScrollabilitydoListextractKeysFromResultSetgetAliasesgetCompositeKeyManyToOneTargetIndicesgetEntityEagerPropertyFetchesgetFactorygetOwnerAssociationTypesgetResultSethasSubselectLoadableCollectionsisSingleRowLoaderisSubselectLoadingEnabledlistloadCollectionloadCollectionBatchloadCollectionSubselectloadEntityloadEntityloadEntityBatchloadSequentialRowsForwardloadSequentialRowsReverseloadSingleRowneedsFetchingScrollpostInstantiateprepareQueryStatementpreprocessSQLscrolltoStringupgradeLocks

Field Detail

collectionAliasesback to summary
private final CollectionAliases[] collectionAliases
collectionOwnersback to summary
private final int[] collectionOwners
collectionPersistersback to summary
private final QueryableCollection[] collectionPersisters
entityAliasesback to summary
private final EntityAliases[] entityAliases
entityPersistersback to summary
private final Queryable[] entityPersisters
entiytOwnersback to summary
private final int[] entiytOwners
lockModesback to summary
private final LockMode[] lockModes
namedParameterBindPointsback to summary
private final Map<K, V> namedParameterBindPoints
querySpacesback to summary
private final Set<E> querySpaces
resultTypesback to summary
private Type[] resultTypes
rowProcessorback to summary
private final CustomLoader.ResultRowProcessor rowProcessor
sqlback to summary
private final String sql
transformerAliasesback to summary
private String[] transformerAliases

Constructor Detail

CustomLoaderback to summary
public CustomLoader(CustomQuery customQuery, SessionFactoryImplementor factory)

Method Detail

autoDiscoverTypesback to summary
protected void autoDiscoverTypes(ResultSet rs)

Overrides org.hibernate.loader.Loader.autoDiscoverTypes.

determineAppropriateOwnerPersisterback to summary
private Queryable determineAppropriateOwnerPersister(NonScalarReturn ownerDescriptor)
getCollectionAliasesback to summary
protected CollectionAliases[] getCollectionAliases()

Implements abstract org.hibernate.loader.Loader.getCollectionAliases.

getCollectionOwnersback to summary
protected int[] getCollectionOwners()

Overrides org.hibernate.loader.Loader.getCollectionOwners.

Doc from org.hibernate.loader.Loader.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.

getCollectionPersistersback to summary
protected CollectionPersister[] getCollectionPersisters()

Overrides org.hibernate.loader.Loader.getCollectionPersisters.

Doc from org.hibernate.loader.Loader.getCollectionPersisters.

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

getEntityAliasesback to summary
protected EntityAliases[] getEntityAliases()

Implements abstract org.hibernate.loader.Loader.getEntityAliases.

Doc from org.hibernate.loader.Loader.getEntityAliases.

Get the result set descriptor

getEntityPersistersback to summary
protected Loadable[] getEntityPersisters()

Implements abstract org.hibernate.loader.Loader.getEntityPersisters.

Doc from org.hibernate.loader.Loader.getEntityPersisters.

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

Returns:Loadable[]

The entity persisters.

getHolderInstantiatorback to summary
private static HolderInstantiator getHolderInstantiator(ResultTransformer resultTransformer, String[] queryReturnAliases)
getLockModesback to summary
protected LockMode[] getLockModes(LockOptions lockOptions)

Implements abstract org.hibernate.loader.Loader.getLockModes.

Doc from org.hibernate.loader.Loader.getLockModes.

What lock options does this load entities with?

Parameters
lockOptions:LockOptions

a collection of lock options specified dynamically via the Query interface

getNamedParameterLocsback to summary
public int[] getNamedParameterLocs(String name) throws QueryException

Overrides org.hibernate.loader.Loader.getNamedParameterLocs.

getOwnersback to summary
protected int[] getOwners()

Overrides org.hibernate.loader.Loader.getOwners.

Doc from org.hibernate.loader.Loader.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"). The indexes contained here are relative to the result of getEntityPersisters.

Returns:int[]

The owner indicators (see discussion above).

getQueryIdentifierback to summary
protected String getQueryIdentifier()

Overrides org.hibernate.loader.Loader.getQueryIdentifier.

Doc from org.hibernate.loader.Loader.getQueryIdentifier.

Identifies the query for statistics reporting, if null, no statistics will be reported

getQuerySpacesback to summary
public Set<E> getQuerySpaces()
getResultColumnOrRowback to summary
protected Object getResultColumnOrRow(Object[] row, ResultTransformer transformer, ResultSet rs, SessionImplementor session) throws SQLException, HibernateException

Overrides org.hibernate.loader.Loader.getResultColumnOrRow.

Doc from org.hibernate.loader.Loader.getResultColumnOrRow.

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.

getResultListback to summary
protected List<E> getResultList(List<E> results, ResultTransformer resultTransformer) throws QueryException

Overrides org.hibernate.loader.Loader.getResultList.

getReturnAliasesForTransformerback to summary
private String[] getReturnAliasesForTransformer()
getSQLStringback to summary
protected String getSQLString()

Implements abstract org.hibernate.loader.Loader.getSQLString.

Doc from org.hibernate.loader.Loader.getSQLString.

The SQL query string to be called; implemented by all subclasses

Returns:String

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

listback to summary
public List<E> list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException
resolveResultTransformerback to summary
protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer)

Overrides org.hibernate.loader.Loader.resolveResultTransformer.

Doc from org.hibernate.loader.Loader.resolveResultTransformer.

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

Parameters
resultTransformer:ResultTransformer

the specified result transformer

Returns:ResultTransformer

the actual result transformer

scrollback to summary
public ScrollableResults scroll(final QueryParameters queryParameters, final SessionImplementor session) throws HibernateException
org.hibernate.loader.custom back to summary

private Class CustomLoader.Metadata

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SessionFactoryImplementor
private final ResultSet
private final ResultSetMetaData

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
public String
getColumnName(int position)

public Type
getHibernateType(int columnPos)

public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
private final SessionFactoryImplementor factory
resultSetback to summary
private final ResultSet resultSet
resultSetMetaDataback to summary
private final ResultSetMetaData resultSetMetaData

Constructor Detail

Metadataback to summary
public Metadata(SessionFactoryImplementor factory, ResultSet resultSet) throws HibernateException

Method Detail

getColumnCountback to summary
public int getColumnCount() throws HibernateException
getColumnNameback to summary
public String getColumnName(int position) throws HibernateException
getHibernateTypeback to summary
public Type getHibernateType(int columnPos) throws SQLException
resolveColumnPositionback to summary
public int resolveColumnPosition(String columnName) throws HibernateException
org.hibernate.loader.custom back to summary

public Class CustomLoader.NonScalarResultColumnProcessor

extends Object
implements ResultColumnProcessor
Class Inheritance
  • java.lang.Object
  • org.hibernate.loader.custom.CustomLoader.NonScalarResultColumnProcessor
All Implemented Interfaces
org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

positionback to summary
private final int position

Constructor Detail

NonScalarResultColumnProcessorback to summary
public NonScalarResultColumnProcessor(int position)

Method Detail

extractback to summary
public Object extract(Object[] data, ResultSet resultSet, SessionImplementor session) throws SQLException, HibernateException

Implements org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor.extract.

performDiscoveryback to summary
public void performDiscovery(CustomLoader.Metadata metadata, List<E> types, List<E> aliases)

Implements org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor.performDiscovery.

org.hibernate.loader.custom back to summary

private Interface CustomLoader.ResultColumnProcessor

Known Direct Implementers
org.hibernate.loader.custom.CustomLoader.NonScalarResultColumnProcessor, org.hibernate.loader.custom.CustomLoader.ScalarResultColumnProcessor

Method Summary

Modifier and TypeMethod and Description
public Object
extract(Object[] data, ResultSet resultSet, SessionImplementor session)

public void
performDiscovery(CustomLoader.Metadata metadata, List<E> types, List<E> aliases)

Method Detail

extractback to summary
public Object extract(Object[] data, ResultSet resultSet, SessionImplementor session) throws SQLException, HibernateException
performDiscoveryback to summary
public void performDiscovery(CustomLoader.Metadata metadata, List<E> types, List<E> aliases) throws SQLException, HibernateException
org.hibernate.loader.custom back to summary

public Class CustomLoader.ResultRowProcessor

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private CustomLoader.ResultColumnProcessor[]
private final boolean

Constructor Summary

AccessConstructor and Description
public
ResultRowProcessor(boolean hasScalars, CustomLoader.ResultColumnProcessor[] columnProcessors)

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

The logical result row
buildResultRow
(Object[]
Entity data defined as "root returns" and already handled by the normal Loader mechanism.
data
,
ResultSet
The JDBC result set (positioned at the row currently being processed).
resultSet
,
boolean
Does this query have an associated ResultTransformer
hasTransformer
,
SessionImplementor
The session from which the query request originated.
session
)

Build a logical result row.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnProcessorsback to summary
private CustomLoader.ResultColumnProcessor[] columnProcessors
hasScalarsback to summary
private final boolean hasScalars

Constructor Detail

ResultRowProcessorback to summary
public ResultRowProcessor(boolean hasScalars, CustomLoader.ResultColumnProcessor[] columnProcessors)

Method Detail

buildResultRowback to summary
public Object buildResultRow(Object[] data, ResultSet resultSet, boolean hasTransformer, SessionImplementor session) throws SQLException, HibernateException

Build a logical result row.

At this point, Loader has already processed all non-scalar result data. We just need to account for scalar result data here...

Parameters
data:Object[]

Entity data defined as "root returns" and already handled by the normal Loader mechanism.

resultSet:ResultSet

The JDBC result set (positioned at the row currently being processed).

hasTransformer:boolean

Does this query have an associated ResultTransformer

session:SessionImplementor

The session from which the query request originated.

Returns:Object

The logical result row

prepareForAutoDiscoveryback to summary
public void prepareForAutoDiscovery(CustomLoader.Metadata metadata) throws SQLException
org.hibernate.loader.custom back to summary

public Class CustomLoader.ScalarResultColumnProcessor

extends Object
implements ResultColumnProcessor
Class Inheritance
  • java.lang.Object
  • org.hibernate.loader.custom.CustomLoader.ScalarResultColumnProcessor
All Implemented Interfaces
org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor

Field Summary

Modifier and TypeField and Description
private String
private int
private Type

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Object
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aliasback to summary
private String alias
positionback to summary
private int position
typeback to summary
private Type type

Constructor Detail

ScalarResultColumnProcessorback to summary
public ScalarResultColumnProcessor(int position)
ScalarResultColumnProcessorback to summary
public ScalarResultColumnProcessor(String alias, Type type)

Method Detail

extractback to summary
public Object extract(Object[] data, ResultSet resultSet, SessionImplementor session) throws SQLException, HibernateException

Implements org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor.extract.

performDiscoveryback to summary
public void performDiscovery(CustomLoader.Metadata metadata, List<E> types, List<E> aliases) throws SQLException

Implements org.hibernate.loader.custom.CustomLoader.ResultColumnProcessor.performDiscovery.