public abstract class

AbstractCollectionPersister

extends Object
implements CollectionMetadata SQLLoadableCollection
java.lang.Object
   ↳ org.hibernate.persister.collection.AbstractCollectionPersister
Known Direct Subclasses

Class Overview

Base implementation of the QueryableCollection interface.

Summary

Fields
protected final int batchSize
protected final String[] elementColumnAliases
protected final boolean[] elementColumnIsInPrimaryKey
protected final boolean[] elementColumnIsSettable
protected final String[] elementColumnNames
protected final String[] elementColumnReaderTemplates
protected final String[] elementColumnReaders
protected final String[] elementColumnWriters
protected final String[] elementFormulaTemplates
protected final String[] elementFormulas
protected final boolean elementIsPureFormula
protected final Type elementType
protected final boolean hasIdentifier
protected final boolean hasIndex
protected final boolean hasWhere
protected final String identifierColumnName
protected final String[] indexColumnAliases
protected final boolean[] indexColumnIsSettable
protected final String[] indexColumnNames
protected final boolean indexContainsFormula
protected final String[] indexFormulaTemplates
protected final String[] indexFormulas
protected final String[] keyColumnAliases
protected final String[] keyColumnNames
protected final String qualifiedTableName
protected final String sqlWhereString
Public Constructors
AbstractCollectionPersister(Collection collection, CollectionRegionAccessStrategy cacheAccessStrategy, Configuration cfg, SessionFactoryImplementor factory)
Public Methods
void deleteRows(PersistentCollection collection, Serializable id, SessionImplementor session)
Delete the persistent state of any elements that were removed from the collection
boolean elementExists(Serializable key, Object element, SessionImplementor session)
String filterFragment(String alias, Map enabledFilters)
Get the where clause filter, given a query alias and considering enabled session filters
CollectionRegionAccessStrategy getCacheAccessStrategy()
Get the cache
CacheEntryStructure getCacheEntryStructure()
Get the cache structure
CollectionMetadata getCollectionMetadata()
String[] getCollectionPropertyColumnAliases(String propertyName, String suffix)
Serializable[] getCollectionSpaces()
Get the "space" that holds the persistent state
CollectionType getCollectionType()
Get the associated Type
Object getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner)
Class getElementClass()
Return the element class of an array, or null otherwise
String[] getElementColumnAliases(String suffix)
Generates the collection's element column aliases, based on the given suffix.
String[] getElementColumnNames(String alias)
Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association), aliased by the given table alias
String[] getElementColumnNames()
Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association)
String getElementNodeName()
EntityPersister getElementPersister()
Get the persister of the element class, if this is a collection of entities (optional operation).
Type getElementType()
The collection element type
SessionFactoryImplementor getFactory()
FetchMode getFetchMode()
Should we load this collection role by outerjoining?
String getIdentifierColumnAlias(String suffix)
Generates the collection's identifier column aliases, based on the given suffix.
String getIdentifierColumnName()
IdentifierGenerator getIdentifierGenerator()
Get the surrogate key generation strategy (optional operation)
Type getIdentifierType()
Get the type of the surrogate key
String[] getIndexColumnAliases(String suffix)
Generates the collection's index column aliases, based on the given suffix.
String[] getIndexColumnNames()
Get the names of the collection index columns if this is an indexed collection (optional operation)
String[] getIndexColumnNames(String alias)
Get the names of the collection index columns if this is an indexed collection (optional operation), aliased by the given table alias
String[] getIndexFormulas()
Get the index formulas if this is an indexed collection (optional operation)
String getIndexNodeName()
Type getIndexType()
The collection index type (or null if the collection has no index)
CollectionInitializer getInitializer()
Intended for internal use only.
String[] getKeyColumnAliases(String suffix)
Generates the collection's key column aliases, based on the given suffix.
String[] getKeyColumnNames()
The columns to join on
Type getKeyType()
The collection key type
String getManyToManyFilterFragment(String alias, Map enabledFilters)
String getManyToManyOrderByString(String alias)
Get the order-by to be applied at the target table of a many to many
String getName()
An identifying name; a class name or collection role name.
String getNodeName()
String getOwnerEntityName()
EntityPersister getOwnerEntityPersister()
Get the persister of the entity that "owns" this collection
String getRole()
The name of this collection role
String getSQLOrderByString(String alias)
Get the order by SQL
int getSize(Serializable key, SessionImplementor session)
String getTableName()
The table to join to.
Type getType()
Get the type of the thing containing the properties
boolean hasCache()
Is this collection role cacheable
boolean hasIndex()
Is this collection indexed?
boolean hasManyToManyOrdering()
boolean hasOrdering()
Is this an ordered collection? (An ordered collection is ordered by the initialization operation, not by sorting that happens in memory, as in the case of a sorted collection.)
boolean hasOrphanDelete()
Does this collection implement "orphan delete"?
boolean hasWhere()
Does this collection role have a where clause filter?
boolean indexExists(Serializable key, Object index, SessionImplementor session)
void initCollectionPropertyMap()
void initialize(Serializable key, SessionImplementor session)
Initialize the given collection with the given key
void insertRows(PersistentCollection collection, Serializable id, SessionImplementor session)
Insert the persistent state of any new collection elements
boolean isAffectedByEnabledFilters(SessionImplementor session)
boolean isArray()
Is the collection an array?
boolean isCollection()
Is this instance actually a CollectionPersister?
boolean isExtraLazy()
boolean isInverse()
Is this collection "inverse", so state changes are not propogated to the database.
boolean isLazy()
Is the collection lazily initialized?
abstract boolean isManyToMany()
Is this a many-to-many association? Note that this is mainly a convenience feature as the single persister does not conatin all the information needed to handle a many-to-many itself, as internally it is looked at as two many-to-ones.
boolean isMutable()
Can the elements of this collection change?
boolean isPrimitiveArray()
Is the collection a primitive array?
boolean isSubselectLoadable()
boolean isVersioned()
Does this collection cause version increment of the owning entity?
String oneToManyFilterFragment(String alias)
void postInstantiate()
Object readElement(ResultSet rs, Object owner, String[] aliases, SessionImplementor session)
Read the element from a row of the JDBC ResultSet
Object readIdentifier(ResultSet rs, String alias, SessionImplementor session)
Read the identifier from a row of the JDBC ResultSet
Object readIndex(ResultSet rs, String[] aliases, SessionImplementor session)
Read the index from a row of the JDBC ResultSet
Object readKey(ResultSet rs, String[] aliases, SessionImplementor session)
Read the key from a row of the JDBC ResultSet
void recreate(PersistentCollection collection, Serializable id, SessionImplementor session)
(Re)create the collection's persistent state
void remove(Serializable id, SessionImplementor session)
Completely remove the persistent state of the collection
String selectFragment(String alias, String columnSuffix)
Generate a list of collection index, key and element columns
String[] toColumns(String alias, String propertyName)
Given a query alias and a property path, return the qualified column name
String[] toColumns(String propertyName)
Given a property path, return the corresponding column name(s).
String toString()
Type toType(String propertyName)
Given a component path expression, get the type of the property
void updateRows(PersistentCollection collection, Serializable id, SessionImplementor session)
Update the persistent state of any elements that were modified
int writeIdentifier(PreparedStatement st, Object id, int i, SessionImplementor session)
Write the identifier to a JDBC PreparedStatement
Protected Methods
void appendElementColumns(SelectFragment frag, String elemAlias)
void appendIdentifierColumns(SelectFragment frag, String alias)
void appendIndexColumns(SelectFragment frag, String alias)
abstract CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers)
abstract CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session)
Object decrementIndexByBase(Object index)
abstract int doUpdateRows(Serializable key, PersistentCollection collection, SessionImplementor session)
String filterFragment(String alias)
abstract String generateDeleteRowString()
abstract String generateDeleteString()
String generateDetectRowByElementString()
String generateDetectRowByIndexString()
abstract String generateInsertRowString()
SelectFragment generateSelectFragment(String alias, String columnSuffix)
String generateSelectRowByIndexString()
String generateSelectSizeString(boolean isIntegerIndexed)
abstract String generateUpdateRowString()
CollectionInitializer getAppropriateInitializer(Serializable key, SessionImplementor session)
ExecuteUpdateResultCheckStyle getDeleteAllCheckStyle()
ExecuteUpdateResultCheckStyle getDeleteCheckStyle()
Dialect getDialect()
ExecuteUpdateResultCheckStyle getInsertCheckStyle()
String getSQLDeleteRowString()
String getSQLDeleteString()
SQLExceptionConverter getSQLExceptionConverter()
String getSQLInsertRowString()
String getSQLUpdateRowString()
String getSQLWhereString(String alias)
ExecuteUpdateResultCheckStyle getUpdateCheckStyle()
Object incrementIndexByBase(Object index)
boolean isDeleteAllCallable()
boolean isDeleteCallable()
boolean isInsertCallable()
boolean isRowDeleteEnabled()
boolean isRowInsertEnabled()
boolean isUpdateCallable()
void logStaticSQL()
int writeElement(PreparedStatement st, Object elt, int i, SessionImplementor session)
Write the element to a JDBC PreparedStatement
int writeElementToWhere(PreparedStatement st, Object elt, int i, SessionImplementor session)
Write the element to a JDBC PreparedStatement
int writeIndex(PreparedStatement st, Object index, int i, SessionImplementor session)
Write the index to a JDBC PreparedStatement
int writeIndexToWhere(PreparedStatement st, Object index, int i, SessionImplementor session)
Write the index to a JDBC PreparedStatement
int writeKey(PreparedStatement st, Serializable key, int i, SessionImplementor session)
Write the key to a JDBC PreparedStatement
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.metadata.CollectionMetadata
From interface org.hibernate.persister.collection.CollectionPersister
From interface org.hibernate.persister.collection.QueryableCollection
From interface org.hibernate.persister.collection.SQLLoadableCollection
From interface org.hibernate.persister.entity.Joinable
From interface org.hibernate.persister.entity.PropertyMapping

Fields

protected final int batchSize

protected final String[] elementColumnAliases

protected final boolean[] elementColumnIsInPrimaryKey

protected final boolean[] elementColumnIsSettable

protected final String[] elementColumnNames

protected final String[] elementColumnReaderTemplates

protected final String[] elementColumnReaders

protected final String[] elementColumnWriters

protected final String[] elementFormulaTemplates

protected final String[] elementFormulas

protected final boolean elementIsPureFormula

protected final Type elementType

protected final boolean hasIdentifier

protected final boolean hasIndex

protected final boolean hasWhere

protected final String identifierColumnName

protected final String[] indexColumnAliases

protected final boolean[] indexColumnIsSettable

protected final String[] indexColumnNames

protected final boolean indexContainsFormula

protected final String[] indexFormulaTemplates

protected final String[] indexFormulas

protected final String[] keyColumnAliases

protected final String[] keyColumnNames

protected final String qualifiedTableName

protected final String sqlWhereString

Public Constructors

public AbstractCollectionPersister (Collection collection, CollectionRegionAccessStrategy cacheAccessStrategy, Configuration cfg, SessionFactoryImplementor factory)

Public Methods

public void deleteRows (PersistentCollection collection, Serializable id, SessionImplementor session)

Delete the persistent state of any elements that were removed from the collection

public boolean elementExists (Serializable key, Object element, SessionImplementor session)

public String filterFragment (String alias, Map enabledFilters)

Get the where clause filter, given a query alias and considering enabled session filters

public CollectionRegionAccessStrategy getCacheAccessStrategy ()

Get the cache

public CacheEntryStructure getCacheEntryStructure ()

Get the cache structure

public CollectionMetadata getCollectionMetadata ()

public String[] getCollectionPropertyColumnAliases (String propertyName, String suffix)

public Serializable[] getCollectionSpaces ()

Get the "space" that holds the persistent state

public CollectionType getCollectionType ()

Get the associated Type

public Object getElementByIndex (Serializable key, Object index, SessionImplementor session, Object owner)

public Class getElementClass ()

Return the element class of an array, or null otherwise

public String[] getElementColumnAliases (String suffix)

Generates the collection's element column aliases, based on the given suffix.

Parameters
suffix The suffix to use in the element column alias generation.
Returns
  • The key column aliases.

public String[] getElementColumnNames (String alias)

Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association), aliased by the given table alias

public String[] getElementColumnNames ()

Get the names of the collection element columns (or the primary key columns in the case of a one-to-many association)

public String getElementNodeName ()

public EntityPersister getElementPersister ()

Get the persister of the element class, if this is a collection of entities (optional operation). Note that for a one-to-many association, the returned persister must be OuterJoinLoadable.

public Type getElementType ()

The collection element type

public SessionFactoryImplementor getFactory ()

public FetchMode getFetchMode ()

Should we load this collection role by outerjoining?

public String getIdentifierColumnAlias (String suffix)

Generates the collection's identifier column aliases, based on the given suffix.

Parameters
suffix The suffix to use in the key column alias generation.
Returns
  • The key column aliases.

public String getIdentifierColumnName ()

public IdentifierGenerator getIdentifierGenerator ()

Get the surrogate key generation strategy (optional operation)

public Type getIdentifierType ()

Get the type of the surrogate key

public String[] getIndexColumnAliases (String suffix)

Generates the collection's index column aliases, based on the given suffix.

Parameters
suffix The suffix to use in the index column alias generation.
Returns
  • The key column aliases, or null if not indexed.

public String[] getIndexColumnNames ()

Get the names of the collection index columns if this is an indexed collection (optional operation)

public String[] getIndexColumnNames (String alias)

Get the names of the collection index columns if this is an indexed collection (optional operation), aliased by the given table alias

public String[] getIndexFormulas ()

Get the index formulas if this is an indexed collection (optional operation)

public String getIndexNodeName ()

public Type getIndexType ()

The collection index type (or null if the collection has no index)

public CollectionInitializer getInitializer ()

Intended for internal use only. In fact really only currently used from test suite for assertion purposes.

Returns
  • The default collection initializer for this persister/collection.

public String[] getKeyColumnAliases (String suffix)

Generates the collection's key column aliases, based on the given suffix.

Parameters
suffix The suffix to use in the key column alias generation.
Returns
  • The key column aliases.

public String[] getKeyColumnNames ()

The columns to join on

public Type getKeyType ()

The collection key type

public String getManyToManyFilterFragment (String alias, Map enabledFilters)

public String getManyToManyOrderByString (String alias)

Get the order-by to be applied at the target table of a many to many

Parameters
alias The alias for the many-to-many target table
Returns
  • appropriate order-by fragment or empty string.

public String getName ()

An identifying name; a class name or collection role name.

public String getNodeName ()

public String getOwnerEntityName ()

public EntityPersister getOwnerEntityPersister ()

Get the persister of the entity that "owns" this collection

public String getRole ()

The name of this collection role

public String getSQLOrderByString (String alias)

Get the order by SQL

public int getSize (Serializable key, SessionImplementor session)

public String getTableName ()

The table to join to.

public Type getType ()

Get the type of the thing containing the properties

public boolean hasCache ()

Is this collection role cacheable

public boolean hasIndex ()

Is this collection indexed?

public boolean hasManyToManyOrdering ()

public boolean hasOrdering ()

Is this an ordered collection? (An ordered collection is ordered by the initialization operation, not by sorting that happens in memory, as in the case of a sorted collection.)

public boolean hasOrphanDelete ()

Does this collection implement "orphan delete"?

public boolean hasWhere ()

Does this collection role have a where clause filter?

public boolean indexExists (Serializable key, Object index, SessionImplementor session)

public void initCollectionPropertyMap ()

public void initialize (Serializable key, SessionImplementor session)

Initialize the given collection with the given key

public void insertRows (PersistentCollection collection, Serializable id, SessionImplementor session)

Insert the persistent state of any new collection elements

public boolean isAffectedByEnabledFilters (SessionImplementor session)

public boolean isArray ()

Is the collection an array?

public boolean isCollection ()

Is this instance actually a CollectionPersister?

public boolean isExtraLazy ()

public boolean isInverse ()

Is this collection "inverse", so state changes are not propogated to the database.

public boolean isLazy ()

Is the collection lazily initialized?

public abstract boolean isManyToMany ()

Is this a many-to-many association? Note that this is mainly a convenience feature as the single persister does not conatin all the information needed to handle a many-to-many itself, as internally it is looked at as two many-to-ones.

public boolean isMutable ()

Can the elements of this collection change?

public boolean isPrimitiveArray ()

Is the collection a primitive array?

public boolean isSubselectLoadable ()

public boolean isVersioned ()

Does this collection cause version increment of the owning entity?

public String oneToManyFilterFragment (String alias)

public void postInstantiate ()

public Object readElement (ResultSet rs, Object owner, String[] aliases, SessionImplementor session)

Read the element from a row of the JDBC ResultSet

public Object readIdentifier (ResultSet rs, String alias, SessionImplementor session)

Read the identifier from a row of the JDBC ResultSet

public Object readIndex (ResultSet rs, String[] aliases, SessionImplementor session)

Read the index from a row of the JDBC ResultSet

public Object readKey (ResultSet rs, String[] aliases, SessionImplementor session)

Read the key from a row of the JDBC ResultSet

public void recreate (PersistentCollection collection, Serializable id, SessionImplementor session)

(Re)create the collection's persistent state

public void remove (Serializable id, SessionImplementor session)

Completely remove the persistent state of the collection

public String selectFragment (String alias, String columnSuffix)

Generate a list of collection index, key and element columns

public String[] toColumns (String alias, String propertyName)

Given a query alias and a property path, return the qualified column name

public String[] toColumns (String propertyName)

Given a property path, return the corresponding column name(s).

public String toString ()

public Type toType (String propertyName)

Given a component path expression, get the type of the property

public void updateRows (PersistentCollection collection, Serializable id, SessionImplementor session)

Update the persistent state of any elements that were modified

public int writeIdentifier (PreparedStatement st, Object id, int i, SessionImplementor session)

Write the identifier to a JDBC PreparedStatement

Protected Methods

protected void appendElementColumns (SelectFragment frag, String elemAlias)

protected void appendIdentifierColumns (SelectFragment frag, String alias)

protected void appendIndexColumns (SelectFragment frag, String alias)

protected abstract CollectionInitializer createCollectionInitializer (LoadQueryInfluencers loadQueryInfluencers)

protected abstract CollectionInitializer createSubselectInitializer (SubselectFetch subselect, SessionImplementor session)

protected Object decrementIndexByBase (Object index)

protected abstract int doUpdateRows (Serializable key, PersistentCollection collection, SessionImplementor session)

protected String filterFragment (String alias)

protected abstract String generateDeleteRowString ()

protected abstract String generateDeleteString ()

protected String generateDetectRowByElementString ()

protected String generateDetectRowByIndexString ()

protected abstract String generateInsertRowString ()

protected SelectFragment generateSelectFragment (String alias, String columnSuffix)

protected String generateSelectRowByIndexString ()

protected String generateSelectSizeString (boolean isIntegerIndexed)

protected abstract String generateUpdateRowString ()

protected CollectionInitializer getAppropriateInitializer (Serializable key, SessionImplementor session)

protected ExecuteUpdateResultCheckStyle getDeleteAllCheckStyle ()

protected ExecuteUpdateResultCheckStyle getDeleteCheckStyle ()

protected Dialect getDialect ()

protected ExecuteUpdateResultCheckStyle getInsertCheckStyle ()

protected String getSQLDeleteRowString ()

protected String getSQLDeleteString ()

protected SQLExceptionConverter getSQLExceptionConverter ()

protected String getSQLInsertRowString ()

protected String getSQLUpdateRowString ()

protected String getSQLWhereString (String alias)

protected ExecuteUpdateResultCheckStyle getUpdateCheckStyle ()

protected Object incrementIndexByBase (Object index)

protected boolean isDeleteAllCallable ()

protected boolean isDeleteCallable ()

protected boolean isInsertCallable ()

protected boolean isRowDeleteEnabled ()

protected boolean isRowInsertEnabled ()

protected boolean isUpdateCallable ()

protected void logStaticSQL ()

protected int writeElement (PreparedStatement st, Object elt, int i, SessionImplementor session)

Write the element to a JDBC PreparedStatement

protected int writeElementToWhere (PreparedStatement st, Object elt, int i, SessionImplementor session)

Write the element to a JDBC PreparedStatement

protected int writeIndex (PreparedStatement st, Object index, int i, SessionImplementor session)

Write the index to a JDBC PreparedStatement

protected int writeIndexToWhere (PreparedStatement st, Object index, int i, SessionImplementor session)

Write the index to a JDBC PreparedStatement

protected int writeKey (PreparedStatement st, Serializable key, int i, SessionImplementor session)

Write the key to a JDBC PreparedStatement