org.hibernate.persister.collection

Class OneToManyPersister

Implemented Interfaces:
CollectionMetadata, CollectionPersister, Joinable, PropertyMapping, QueryableCollection, SQLLoadableCollection

public class OneToManyPersister
extends AbstractCollectionPersister

Collection persister for one-to-many associations.
Author:
Gavin King

Field Summary

Fields inherited from class org.hibernate.persister.collection.AbstractCollectionPersister

batchSize, elementColumnAliases, elementColumnIsInPrimaryKey, elementColumnIsSettable, elementColumnNames, elementFormulaTemplates, elementFormulas, elementIsPureFormula, elementType, hasIdentifier, hasIndex, hasWhere, identifierColumnName, indexColumnAliases, indexColumnIsSettable, indexColumnNames, indexContainsFormula, indexFormulaTemplates, indexFormulas, keyColumnAliases, keyColumnNames, qualifiedTableName, sqlWhereString

Constructor Summary

OneToManyPersister(Collection collection, CollectionRegionAccessStrategy cacheAccessStrategy, Configuration cfg, SessionFactoryImplementor factory)

Method Summary

boolean
consumesCollectionAlias()
Very, very, very ugly...
boolean
consumesEntityAlias()
Very, very, very ugly...
protected CollectionInitializer
createCollectionInitializer(java.util.Map enabledFilters)
Create the OneToManyLoader
protected CollectionInitializer
createSubselectInitializer(SubselectFetch subselect, SessionImplementor session)
protected int
doUpdateRows(Serializable id, PersistentCollection collection, SessionImplementor session)
String
filterFragment(String alias)
String
fromJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
Get the from clause part of any joins (optional operation)
protected String
generateDeleteRowString()
Generate the SQL UPDATE that updates a particular row's foreign key to null
protected String
generateDeleteString()
Generate the SQL UPDATE that updates all the foreign keys to null
protected String
generateInsertRowString()
Generate the SQL UPDATE that updates a foreign key to a value
protected String
generateUpdateRowString()
Not needed for one-to-many association
Object
getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner)
String
getTableName()
The table to join to.
boolean
isCascadeDeleteEnabled()
Is cascade delete handled by the database-level foreign key constraint definition?
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
isOneToMany()
Is this a one-to-many association?
protected boolean
isRowDeleteEnabled()
protected boolean
isRowInsertEnabled()
String
selectFragment(Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns)
All columns to select, when loading.
String
whereJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
Get the where clause part of any joins (optional operation)

Methods inherited from class org.hibernate.persister.collection.AbstractCollectionPersister

appendElementColumns, appendIdentifierColumns, appendIndexColumns, createCollectionInitializer, createSubselectInitializer, decrementIndexByBase, deleteRows, doUpdateRows, elementExists, filterFragment, filterFragment, generateDeleteRowString, generateDeleteString, generateDetectRowByElementString, generateDetectRowByIndexString, generateInsertRowString, generateSelectFragment, generateSelectRowByIndexString, generateSelectSizeString, generateUpdateRowString, getAppropriateInitializer, getCacheAccessStrategy, getCacheEntryStructure, getCollectionMetadata, getCollectionPropertyColumnAliases, getCollectionSpaces, getCollectionType, getDeleteAllCheckStyle, getDeleteCheckStyle, getDialect, getElementByIndex, getElementClass, getElementColumnAliases, getElementColumnNames, getElementColumnNames, getElementNodeName, getElementPersister, getElementType, getFactory, getFetchMode, getIdentifierColumnAlias, getIdentifierColumnName, getIdentifierGenerator, getIdentifierType, getIndexColumnAliases, getIndexColumnNames, getIndexColumnNames, getIndexFormulas, getIndexNodeName, getIndexType, getInsertCheckStyle, getKeyColumnAliases, getKeyColumnNames, getKeyType, getManyToManyFilterFragment, getManyToManyOrderByString, getName, getNodeName, getOwnerEntityName, getOwnerEntityPersister, getRole, getSQLDeleteRowString, getSQLDeleteString, getSQLExceptionConverter, getSQLInsertRowString, getSQLOrderByString, getSQLUpdateRowString, getSQLWhereString, getSize, getTableName, getType, getUpdateCheckStyle, hasCache, hasIndex, hasManyToManyOrdering, hasOrdering, hasOrphanDelete, hasWhere, incrementIndexByBase, indexExists, initCollectionPropertyMap, initialize, insertRows, isAffectedByEnabledFilters, isArray, isCollection, isDeleteAllCallable, isDeleteCallable, isExtraLazy, isInsertCallable, isInverse, isLazy, isManyToMany, isMutable, isPrimitiveArray, isRowDeleteEnabled, isRowInsertEnabled, isSubselectLoadable, isUpdateCallable, isVersioned, logStaticSQL, oneToManyFilterFragment, postInstantiate, readElement, readIdentifier, readIndex, readKey, recreate, remove, selectFragment, toColumns, toColumns, toString, toType, updateRows, writeElement, writeElementToWhere, writeIdentifier, writeIndex, writeIndexToWhere, writeKey

Constructor Details

OneToManyPersister

public OneToManyPersister(Collection collection,
                          CollectionRegionAccessStrategy cacheAccessStrategy,
                          Configuration cfg,
                          SessionFactoryImplementor factory)
            throws MappingException,
                   CacheException

Method Details

consumesCollectionAlias

public boolean consumesCollectionAlias()
Very, very, very ugly...
Specified by:
consumesCollectionAlias in interface Joinable
Returns:
Does this persister "consume" collection column aliases in the result set?

consumesEntityAlias

public boolean consumesEntityAlias()
Very, very, very ugly...
Specified by:
consumesEntityAlias in interface Joinable
Returns:
Does this persister "consume" entity column aliases in the result set?

createCollectionInitializer

protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters)
            throws MappingException
Create the OneToManyLoader

createSubselectInitializer

protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect,
                                                           SessionImplementor session)
Overrides:
createSubselectInitializer in interface AbstractCollectionPersister

doUpdateRows

protected int doUpdateRows(Serializable id,
                           PersistentCollection collection,
                           SessionImplementor session)
            throws HibernateException
Overrides:
doUpdateRows in interface AbstractCollectionPersister

filterFragment

public String filterFragment(String alias)
            throws MappingException
Overrides:
filterFragment in interface AbstractCollectionPersister

fromJoinFragment

public String fromJoinFragment(String alias,
                               boolean innerJoin,
                               boolean includeSubclasses)
Get the from clause part of any joins (optional operation)
Specified by:
fromJoinFragment in interface Joinable

generateDeleteRowString

protected String generateDeleteRowString()
Generate the SQL UPDATE that updates a particular row's foreign key to null
Overrides:
generateDeleteRowString in interface AbstractCollectionPersister

generateDeleteString

protected String generateDeleteString()
Generate the SQL UPDATE that updates all the foreign keys to null
Overrides:
generateDeleteString in interface AbstractCollectionPersister

generateInsertRowString

protected String generateInsertRowString()
Generate the SQL UPDATE that updates a foreign key to a value
Overrides:
generateInsertRowString in interface AbstractCollectionPersister

generateUpdateRowString

protected String generateUpdateRowString()
Not needed for one-to-many association
Overrides:
generateUpdateRowString in interface AbstractCollectionPersister

getElementByIndex

public Object getElementByIndex(Serializable key,
                                Object index,
                                SessionImplementor session,
                                Object owner)
Specified by:
getElementByIndex in interface CollectionPersister
Overrides:
getElementByIndex in interface AbstractCollectionPersister

getTableName

public String getTableName()
The table to join to.
Specified by:
getTableName in interface Joinable
Overrides:
getTableName in interface AbstractCollectionPersister

isCascadeDeleteEnabled

public boolean isCascadeDeleteEnabled()
Is cascade delete handled by the database-level foreign key constraint definition?
Specified by:
isCascadeDeleteEnabled in interface CollectionPersister

isManyToMany

public 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.
Specified by:
isManyToMany in interface CollectionPersister
Overrides:
isManyToMany in interface AbstractCollectionPersister

isOneToMany

public boolean isOneToMany()
Is this a one-to-many association?
Specified by:
isOneToMany in interface CollectionPersister

isRowDeleteEnabled

protected boolean isRowDeleteEnabled()
Overrides:
isRowDeleteEnabled in interface AbstractCollectionPersister

isRowInsertEnabled

protected boolean isRowInsertEnabled()
Overrides:
isRowInsertEnabled in interface AbstractCollectionPersister

selectFragment

public String selectFragment(Joinable rhs,
                             String rhsAlias,
                             String lhsAlias,
                             String entitySuffix,
                             String collectionSuffix,
                             boolean includeCollectionColumns)
All columns to select, when loading.
Specified by:
selectFragment in interface Joinable

whereJoinFragment

public String whereJoinFragment(String alias,
                                boolean innerJoin,
                                boolean includeSubclasses)
Get the where clause part of any joins (optional operation)
Specified by:
whereJoinFragment in interface Joinable