Interface CollectionPersister
-
- All Superinterfaces:
CollectionDefinition
- All Known Subinterfaces:
QueryableCollection,SQLLoadableCollection
- All Known Implementing Classes:
AbstractCollectionPersister,BasicCollectionPersister,OneToManyPersister
public interface CollectionPersister extends CollectionDefinition
A strategy for persisting a collection role. Defines a contract between the persistence strategy and the actual persistent collection framework and session. Does not define operations that are required for querying collections, or loading by outer join.
Implements persistence of a collection instance while the instance is referenced in a particular role.
This class is highly coupled to the PersistentCollection hierarchy, since double dispatch is used to load and update collection elements.
May be considered an immutable view of the mapping object Unless a customerPersisterFactoryis used, it is expected that implementations of CollectionDefinition define a constructor accepting the following arguments:-
Collection- The metadata about the collection to be handled by the persister -
CollectionDataAccess- the second level caching strategy for this collection -
PersisterCreationContext- access to additional information useful while constructing the persister.
- See Also:
QueryableCollection,PersistentCollection
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddeleteRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session)Delete the persistent state of any elements that were removed from the collectionbooleanelementExists(java.io.Serializable key, java.lang.Object element, SharedSessionContractImplementor session)intgetBatchSize()CollectionDataAccessgetCacheAccessStrategy()Get the cacheCacheEntryStructuregetCacheEntryStructure()Get the cache structureCollectionMetadatagetCollectionMetadata()java.io.Serializable[]getCollectionSpaces()Get the "space" that holds the persistent stateCollectionTypegetCollectionType()Get the associated Typejava.lang.ObjectgetElementByIndex(java.io.Serializable key, java.lang.Object index, SharedSessionContractImplementor session, java.lang.Object owner)java.lang.ClassgetElementClass()Return the element class of an array, or null otherwisejava.lang.String[]getElementColumnAliases(java.lang.String suffix)Generates the collection's element column aliases, based on the given suffix.TypegetElementType()Get the "element" typeSessionFactoryImplementorgetFactory()java.lang.StringgetIdentifierColumnAlias(java.lang.String suffix)Generates the collection's identifier column aliases, based on the given suffix.IdentifierGeneratorgetIdentifierGenerator()Get the surrogate key generation strategy (optional operation)TypegetIdentifierType()Get the type of the surrogate keyjava.lang.String[]getIndexColumnAliases(java.lang.String suffix)Generates the collection's index column aliases, based on the given suffix.TypegetIndexType()Get the "index" type for a list or map (optional operation)java.lang.String[]getKeyColumnAliases(java.lang.String suffix)Generates the collection's key column aliases, based on the given suffix.TypegetKeyType()Get the "key" type (the type of the foreign key)java.lang.StringgetManyToManyFilterFragment(java.lang.String alias, java.util.Map enabledFilters)java.lang.StringgetMappedByProperty()NavigableRolegetNavigableRole()EntityPersistergetOwnerEntityPersister()Get the persister of the entity that "owns" this collectionjava.lang.StringgetRole()Get the name of this collection role (the fully qualified class name, extended by a "property path")intgetSize(java.io.Serializable key, SharedSessionContractImplementor session)booleanhasCache()Is this collection role cacheablebooleanhasIndex()Is this an "indexed" collection? (list or map)booleanhasManyToManyOrdering()booleanhasOrdering()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.)booleanhasOrphanDelete()Does this collection implement "orphan delete"?booleanindexExists(java.io.Serializable key, java.lang.Object index, SharedSessionContractImplementor session)voidinitialize(java.io.Serializable key, SharedSessionContractImplementor session)Initialize the given collection with the given key TODO: add owner argument!!voidinsertRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session)Insert the persistent state of any new collection elementsbooleanisAffectedByEnabledFilters(SharedSessionContractImplementor session)booleanisArray()Is this an array?booleanisCascadeDeleteEnabled()Is cascade delete handled by the database-level foreign key constraint definition?booleanisExtraLazy()booleanisInverse()Is this collection "inverse", so state changes are not propagated to the database.booleanisLazy()Is this collection lazyily initialized?booleanisManyToMany()Is this a many-to-many association? Note that this is mainly a convenience feature as the single persister does not contain all the information needed to handle a many-to-many itself, as internally it is looked at as two many-to-ones.booleanisMutable()Can the elements of this collection change?booleanisOneToMany()Is this a one-to-many association?booleanisPrimitiveArray()Is this an array or primitive values?booleanisVersioned()Does this collection cause version increment of the owning entity?voidpostInstantiate()voidprocessQueuedOps(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session)Process queued operations within the PersistentCollection.java.lang.ObjectreadElement(java.sql.ResultSet rs, java.lang.Object owner, java.lang.String[] columnAliases, SharedSessionContractImplementor session)Read the element from a row of the JDBC ResultSetjava.lang.ObjectreadIdentifier(java.sql.ResultSet rs, java.lang.String columnAlias, SharedSessionContractImplementor session)Read the identifier from a row of the JDBC ResultSetjava.lang.ObjectreadIndex(java.sql.ResultSet rs, java.lang.String[] columnAliases, SharedSessionContractImplementor session)Read the index from a row of the JDBC ResultSetjava.lang.ObjectreadKey(java.sql.ResultSet rs, java.lang.String[] keyAliases, SharedSessionContractImplementor session)Read the key from a row of the JDBC ResultSetvoidrecreate(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session)(Re)create the collection's persistent statevoidremove(java.io.Serializable id, SharedSessionContractImplementor session)Completely remove the persistent state of the collectionvoidupdateRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session)Update the persistent state of any elements that were modified-
Methods inherited from interface org.hibernate.persister.walking.spi.CollectionDefinition
getCollectionPersister, getElementDefinition, getIndexDefinition
-
-
-
-
Method Detail
-
initialize
void initialize(java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateExceptionInitialize the given collection with the given key TODO: add owner argument!!- Throws:
HibernateException
-
hasCache
boolean hasCache()
Is this collection role cacheable
-
getCacheAccessStrategy
CollectionDataAccess getCacheAccessStrategy()
Get the cache
-
getNavigableRole
NavigableRole getNavigableRole()
-
getCacheEntryStructure
CacheEntryStructure getCacheEntryStructure()
Get the cache structure
-
getCollectionType
CollectionType getCollectionType()
Get the associated Type- Specified by:
getCollectionTypein interfaceCollectionDefinition
-
getKeyType
Type getKeyType()
Get the "key" type (the type of the foreign key)
-
getIndexType
Type getIndexType()
Get the "index" type for a list or map (optional operation)
-
getElementType
Type getElementType()
Get the "element" type
-
getElementClass
java.lang.Class getElementClass()
Return the element class of an array, or null otherwise
-
readKey
java.lang.Object readKey(java.sql.ResultSet rs, java.lang.String[] keyAliases, SharedSessionContractImplementor session) throws HibernateException, java.sql.SQLExceptionRead the key from a row of the JDBC ResultSet- Throws:
HibernateExceptionjava.sql.SQLException
-
readElement
java.lang.Object readElement(java.sql.ResultSet rs, java.lang.Object owner, java.lang.String[] columnAliases, SharedSessionContractImplementor session) throws HibernateException, java.sql.SQLExceptionRead the element from a row of the JDBC ResultSet- Throws:
HibernateExceptionjava.sql.SQLException
-
readIndex
java.lang.Object readIndex(java.sql.ResultSet rs, java.lang.String[] columnAliases, SharedSessionContractImplementor session) throws HibernateException, java.sql.SQLExceptionRead the index from a row of the JDBC ResultSet- Throws:
HibernateExceptionjava.sql.SQLException
-
readIdentifier
java.lang.Object readIdentifier(java.sql.ResultSet rs, java.lang.String columnAlias, SharedSessionContractImplementor session) throws HibernateException, java.sql.SQLExceptionRead the identifier from a row of the JDBC ResultSet- Throws:
HibernateExceptionjava.sql.SQLException
-
isPrimitiveArray
boolean isPrimitiveArray()
Is this an array or primitive values?
-
isArray
boolean isArray()
Is this an array?
-
isOneToMany
boolean isOneToMany()
Is this a one-to-many association?
-
isManyToMany
boolean isManyToMany()
Is this a many-to-many association? Note that this is mainly a convenience feature as the single persister does not contain all the information needed to handle a many-to-many itself, as internally it is looked at as two many-to-ones.
-
getManyToManyFilterFragment
java.lang.String getManyToManyFilterFragment(java.lang.String alias, java.util.Map enabledFilters)
-
hasIndex
boolean hasIndex()
Is this an "indexed" collection? (list or map)
-
isLazy
boolean isLazy()
Is this collection lazyily initialized?
-
isInverse
boolean isInverse()
Is this collection "inverse", so state changes are not propagated to the database.
-
remove
void remove(java.io.Serializable id, SharedSessionContractImplementor session) throws HibernateExceptionCompletely remove the persistent state of the collection- Throws:
HibernateException
-
recreate
void recreate(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateException
(Re)create the collection's persistent state- Throws:
HibernateException
-
deleteRows
void deleteRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateException
Delete the persistent state of any elements that were removed from the collection- Throws:
HibernateException
-
updateRows
void updateRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateException
Update the persistent state of any elements that were modified- Throws:
HibernateException
-
insertRows
void insertRows(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateException
Insert the persistent state of any new collection elements- Throws:
HibernateException
-
processQueuedOps
void processQueuedOps(PersistentCollection collection, java.io.Serializable key, SharedSessionContractImplementor session) throws HibernateException
Process queued operations within the PersistentCollection.- Throws:
HibernateException
-
getRole
java.lang.String getRole()
Get the name of this collection role (the fully qualified class name, extended by a "property path")
-
getOwnerEntityPersister
EntityPersister getOwnerEntityPersister()
Get the persister of the entity that "owns" this collection
-
getIdentifierGenerator
IdentifierGenerator getIdentifierGenerator()
Get the surrogate key generation strategy (optional operation)
-
getIdentifierType
Type getIdentifierType()
Get the type of the surrogate key
-
hasOrphanDelete
boolean hasOrphanDelete()
Does this collection implement "orphan delete"?
-
hasOrdering
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.)
-
hasManyToManyOrdering
boolean hasManyToManyOrdering()
-
getCollectionSpaces
java.io.Serializable[] getCollectionSpaces()
Get the "space" that holds the persistent state
-
getCollectionMetadata
CollectionMetadata getCollectionMetadata()
-
isCascadeDeleteEnabled
boolean isCascadeDeleteEnabled()
Is cascade delete handled by the database-level foreign key constraint definition?
-
isVersioned
boolean isVersioned()
Does this collection cause version increment of the owning entity?
-
isMutable
boolean isMutable()
Can the elements of this collection change?
-
postInstantiate
void postInstantiate() throws MappingException- Throws:
MappingException
-
getFactory
SessionFactoryImplementor getFactory()
-
isAffectedByEnabledFilters
boolean isAffectedByEnabledFilters(SharedSessionContractImplementor session)
-
getKeyColumnAliases
java.lang.String[] getKeyColumnAliases(java.lang.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.
-
getIndexColumnAliases
java.lang.String[] getIndexColumnAliases(java.lang.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.
-
getElementColumnAliases
java.lang.String[] getElementColumnAliases(java.lang.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.
-
getIdentifierColumnAlias
java.lang.String getIdentifierColumnAlias(java.lang.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.
-
isExtraLazy
boolean isExtraLazy()
-
getSize
int getSize(java.io.Serializable key, SharedSessionContractImplementor session)
-
indexExists
boolean indexExists(java.io.Serializable key, java.lang.Object index, SharedSessionContractImplementor session)
-
elementExists
boolean elementExists(java.io.Serializable key, java.lang.Object element, SharedSessionContractImplementor session)
-
getElementByIndex
java.lang.Object getElementByIndex(java.io.Serializable key, java.lang.Object index, SharedSessionContractImplementor session, java.lang.Object owner)
-
getBatchSize
int getBatchSize()
-
getMappedByProperty
java.lang.String getMappedByProperty()
- Returns:
- the name of the property this collection is mapped by
-
-