Interface CollectionPersister
-
- All Superinterfaces:
FilterRestrictable
,Restrictable
,WhereRestrictable
- All Known Subinterfaces:
DeprecatedCollectionStuff
,QueryableCollection
,SQLLoadableCollection
- All Known Implementing Classes:
AbstractCollectionPersister
,BasicCollectionPersister
,MockCollectionPersister
,OneToManyPersister
,ProcessorSessionFactory.ElementCollectionPersister
,ProcessorSessionFactory.ToManyAssociationPersister
public interface CollectionPersister extends Restrictable
A strategy for persisting a mapped collection role. ACollectionPersister
orchestrates rendering of SQL statements corresponding to basic lifecycle events, includinginsert
,update
, anddelete
statements, and their execution via JDBC.Concrete implementations of this interface handle one-to-many and many-to-many association cardinalities, and to a certain extent abstract the details of those mappings from collaborators.
Note that an instance of
PersistentCollection
may change roles. This object implements persistence of a collection instance while the instance is referenced in a particular role.This interface defines a contract between the persistence strategy and the actual persistent collection framework and
session
. It does not define operations that are required for querying collections, nor for loading by outer join. Implementations are highly coupled to thePersistentCollection
hierarchy, since double dispatch is used to load and update collection elements.Unless a custom
PersisterFactory
is used, it is expected that implementations ofCollectionPersister
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, and -
RuntimeModelCreationContext
- access to additional information useful while constructing the persister.
- See Also:
PersistentCollection
,PluralAttributeMapping
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
applyBaseManyToManyRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState)
void
deleteRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Delete the persistent state of any elements that were removed from the collectionboolean
elementExists(Object key, Object element, SharedSessionContractImplementor session)
default PluralAttributeMapping
getAttributeMapping()
default int
getBatchSize()
CollectionDataAccess
getCacheAccessStrategy()
Access to the collection's cache regionCacheEntryStructure
getCacheEntryStructure()
Get the structure used to store data into the collection's cache regionCollectionMetadata
getCollectionMetadata()
Deprecated.This operation is no longer called by Hibernate.CollectionSemantics<?,?>
getCollectionSemantics()
String[]
getCollectionSpaces()
Get the "space" that holds the persistent stateCollectionType
getCollectionType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
.Object
getElementByIndex(Object key, Object index, SharedSessionContractImplementor session, Object owner)
Class<?>
getElementClass()
Return the element class of an array, or null otherwiseString[]
getElementColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant.Type
getElementType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
.SessionFactoryImplementor
getFactory()
default BeforeExecutionGenerator
getGenerator()
Get the surrogate key generation strategy (optional operation)String
getIdentifierColumnAlias(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant.IdentifierGenerator
getIdentifierGenerator()
Deprecated.usegetGenerator()
Type
getIdentifierType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
.String[]
getIndexColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant.Type
getIndexType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
.String[]
getKeyColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant.Type
getKeyType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
.String
getManyToManyFilterFragment(TableGroup tableGroup, Map<String,Filter> enabledFilters)
String
getMappedByProperty()
NavigableRole
getNavigableRole()
The NavigableRole for this collection.EntityPersister
getOwnerEntityPersister()
Get the persister of the entity that "owns" this collectiondefault String
getRole()
int
getSize(Object key, SharedSessionContractImplementor session)
Comparator<?>
getSortingComparator()
For sorted collections, the comparator to use.boolean
hasCache()
Is this collection role cacheableboolean
hasIndex()
Is this an "indexed" collection? (list or map)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
indexExists(Object key, Object index, SharedSessionContractImplementor session)
void
initialize(Object key, SharedSessionContractImplementor session)
Initialize the given collection with the given keyvoid
insertRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Insert the persistent state of any new collection elementsdefault boolean
isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)
default boolean
isAffectedByEnabledFilters(LoadQueryInfluencers influencers)
boolean
isAffectedByEnabledFilters(SharedSessionContractImplementor session)
default boolean
isAffectedByEntityGraph(LoadQueryInfluencers influencers)
boolean
isArray()
Is this an array?default boolean
isBatchLoadable()
boolean
isCascadeDeleteEnabled()
Is cascade delete handled by the database-level foreign key constraint definition?default boolean
isExtraLazy()
boolean
isInverse()
Is this collection "inverse", so state changes are not propagated to the database.boolean
isLazy()
Is this collection lazily initialized?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.boolean
isMutable()
Can the elements of this collection change?boolean
isOneToMany()
Is this a one-to-many association?boolean
isPrimitiveArray()
Is this an array or primitive values?default boolean
isSubselectLoadable()
boolean
isVersioned()
Does this collection cause version increment of the owning entity?default boolean
needsRemove()
Whetherremove(Object, SharedSessionContractImplementor)
might actually do something, or if it is definitely a no-op.void
postInstantiate()
void
processQueuedOps(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Process queued operations within the PersistentCollection.void
recreate(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
(Re)create the collection's persistent statevoid
remove(Object id, SharedSessionContractImplementor session)
Completely remove the persistent state of the collectionvoid
updateRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Update the persistent state of any elements that were modified-
Methods inherited from interface org.hibernate.metamodel.mapping.FilterRestrictable
applyFilterRestrictions
-
Methods inherited from interface org.hibernate.metamodel.mapping.Restrictable
applyBaseRestrictions
-
Methods inherited from interface org.hibernate.metamodel.mapping.WhereRestrictable
applyWhereRestrictions, hasWhereRestrictions
-
-
-
-
Method Detail
-
getNavigableRole
NavigableRole getNavigableRole()
The NavigableRole for this collection.
-
getRole
default String getRole()
-
getAttributeMapping
default PluralAttributeMapping getAttributeMapping()
-
getOwnerEntityPersister
EntityPersister getOwnerEntityPersister()
Get the persister of the entity that "owns" this collection
-
initialize
void initialize(Object key, SharedSessionContractImplementor session) throws HibernateException
Initialize the given collection with the given key- Throws:
HibernateException
-
hasCache
boolean hasCache()
Is this collection role cacheable
-
needsRemove
default boolean needsRemove()
Whetherremove(Object, SharedSessionContractImplementor)
might actually do something, or if it is definitely a no-op.
-
getCacheAccessStrategy
CollectionDataAccess getCacheAccessStrategy()
Access to the collection's cache region
-
getCacheEntryStructure
CacheEntryStructure getCacheEntryStructure()
Get the structure used to store data into the collection's cache region
-
getElementClass
Class<?> getElementClass()
Return the element class of an array, or null otherwise
-
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
String getManyToManyFilterFragment(TableGroup tableGroup, Map<String,Filter> enabledFilters)
-
hasIndex
boolean hasIndex()
Is this an "indexed" collection? (list or map)
-
isLazy
boolean isLazy()
Is this collection lazily initialized?
-
isInverse
boolean isInverse()
Is this collection "inverse", so state changes are not propagated to the database.
-
remove
void remove(Object id, SharedSessionContractImplementor session)
Completely remove the persistent state of the collection
-
recreate
void recreate(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
(Re)create the collection's persistent state
-
deleteRows
void deleteRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Delete the persistent state of any elements that were removed from the collection
-
updateRows
void updateRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Update the persistent state of any elements that were modified
-
insertRows
void insertRows(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Insert the persistent state of any new collection elements
-
processQueuedOps
void processQueuedOps(PersistentCollection<?> collection, Object key, SharedSessionContractImplementor session)
Process queued operations within the PersistentCollection.
-
getIdentifierGenerator
@Deprecated IdentifierGenerator getIdentifierGenerator()
Deprecated.usegetGenerator()
Get the surrogate key generation strategy (optional operation)
-
getGenerator
default BeforeExecutionGenerator getGenerator()
Get the surrogate key generation strategy (optional operation)
-
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
String[] getCollectionSpaces()
Get the "space" that holds the persistent state
-
getCollectionMetadata
@Deprecated(since="6.0") CollectionMetadata getCollectionMetadata()
Deprecated.This operation is no longer called by Hibernate.Get the user-visible metadata for the collection (optional operation)
-
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)
-
isAffectedByEnabledFilters
default boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers)
-
isAffectedByEntityGraph
default boolean isAffectedByEntityGraph(LoadQueryInfluencers influencers)
-
isAffectedByEnabledFetchProfiles
default boolean isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)
-
isExtraLazy
default boolean isExtraLazy()
-
getSize
int getSize(Object key, SharedSessionContractImplementor session)
-
indexExists
boolean indexExists(Object key, Object index, SharedSessionContractImplementor session)
-
elementExists
boolean elementExists(Object key, Object element, SharedSessionContractImplementor session)
-
getElementByIndex
Object getElementByIndex(Object key, Object index, SharedSessionContractImplementor session, Object owner)
-
getBatchSize
default int getBatchSize()
-
isBatchLoadable
default boolean isBatchLoadable()
-
isSubselectLoadable
default boolean isSubselectLoadable()
-
getMappedByProperty
String getMappedByProperty()
- Returns:
- the name of the property this collection is mapped by
-
getSortingComparator
Comparator<?> getSortingComparator()
For sorted collections, the comparator to use. Non-parameterized because for SORTED_SET the elements are compared but for SORTED_MAP the keys are compared
-
getCollectionSemantics
CollectionSemantics<?,?> getCollectionSemantics()
-
applyBaseManyToManyRestrictions
void applyBaseManyToManyRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState)
-
getKeyColumnAliases
@Deprecated(since="6", forRemoval=true) String[] getKeyColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant. Currently still used bySQLQueryParser
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
@Deprecated(since="6", forRemoval=true) String[] getIndexColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant. Currently still used bySQLQueryParser
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
@Deprecated(since="6", forRemoval=true) String[] getElementColumnAliases(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant. Currently still used bySQLQueryParser
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
@Deprecated(since="6", forRemoval=true) String getIdentifierColumnAlias(String suffix)
Deprecated, for removal: This API element is subject to removal in a future version.Read-by-position makes this irrelevant. Currently still used bySQLQueryParser
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.
-
getCollectionType
@Deprecated(forRemoval=true) CollectionType getCollectionType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
. Corresponding mapping metamodel calls should be used instead - here (generally),PluralAttributeMapping
Get the associatedType
-
getKeyType
@Deprecated(forRemoval=true) Type getKeyType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
. Corresponding mapping metamodel calls should be used instead - here,PluralAttributeMapping.getKeyDescriptor()
Get the "key" type (the type of the foreign key)
-
getIndexType
@Deprecated(forRemoval=true) Type getIndexType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
. Corresponding mapping metamodel calls should be used instead - here,PluralAttributeMapping.getIndexDescriptor()
Get the "index" type for a list or map (optional operation)
-
getElementType
@Deprecated(forRemoval=true) Type getElementType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
. Corresponding mapping metamodel calls should be used instead - here,PluralAttributeMapping.getElementDescriptor()
Get the "element" type
-
getIdentifierType
@Deprecated(forRemoval=true) Type getIdentifierType()
Deprecated, for removal: This API element is subject to removal in a future version.Hibernate is moving away fromType
. Corresponding mapping metamodel calls should be used instead - here,PluralAttributeMapping.getIdentifierDescriptor()
Get the type of the surrogate key
-
-