Hibernate "wraps" a Java collection in an instance of
PersistentCollection. This mechanism is allows for
tracking of changes to the persistent state of the collection and
lazy fetching of the collection elements. The downside is that
only certain abstract collection types are supported and any
extra semantics associated with the particular implementation of
the generic collection type are lost. For example, every
java. behaves like an ArrayList, and
every java. behaves like a TreeMap.
Applications should never use classes in this package directly, unless extending the "framework" here.
Changes to structure of the collection are recorded by the collection calling back to the session. Changes to mutable elements (composite elements) are discovered by cloning their state when the collection is initialized and comparing at flush time.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public void | afterRowInsert(CollectionPersister
The collection persister persister, Object The collection element just inserted entry, int The element position/index i)Called after inserting a row, to fetch the natively generated id |
| public void | beforeInitialize(CollectionPersister persister, int anticipatedSize)
Called prior to the initialization of this yet-uninitialized collection. |
| public void | |
| public void | |
| public void | |
| public Object | Returns: The disassembled stateThe collection persister persister)Disassemble the collection to get it ready for the cache |
| public Object | elementByIndex(Object index)
Obtain the element os this collection associated with the given index without initializing it |
| public boolean | elementExists(Object element)
Determine if the given element belongs to this collection without initializing it |
| public boolean | |
| public boolean | |
| public Iterator | Returns: The iteratorThe collection persister. persister)Iterate all collection entries, during update of the database |
| public boolean | Returns: true if the given entry is a collection elementThe object to check if it exists as a collection element entry, int Unused i)Does the given element/entry exist in the collection? |
| public boolean | Returns: true if the current state and the snapshot state match.The collection persister persister)Does the current state exactly match the snapshot? |
| public Iterator | Returns: An iterator over the elements to deleteThe collection persister persister, boolean For indexed collections, tells whether the index is a formula (calculated value) mapping indexIsFormula)Get all the elements that need deleting |
| public Object | Returns: The corresponding object that is part of the collection elements.The object instance for which to get the collection element instance. entry)Get the value of the given collection entry. |
| public Object | Returns: The identifier valueThe collection entry/element entry, int The assumed identifier (?) i)Get the identifier of the given collection entry. |
| public Object | Returns: The index valueThe collection entry/element entry, int The assumed index i, CollectionPersister it was more elegant before we added this... persister)Get the index of the given collection entry |
| public Object | |
| public Collection | Returns: The orphansThe snapshot state snapshot, String The name of the entity that are the elements of the collection entityName)get all "orphaned" elements |
| public Object | |
| public Collection | Returns: The orphaned elementsThe name of the entity that makes up the elements entityName)Get the "queued" orphans |
| public String | |
| public int | |
| public Serializable | Returns: The snapshotThe collection persister persister)Return a new snapshot of the current state of the collection |
| public Object | Returns: The snapshot state for that elementThe entry entry, int The index i)Get the snapshot value of the given collection entry |
| public Serializable | Returns: The internally stored snapshot stateGet the snapshot cached by the collection instance |
| public Object | Returns: The underlying collection/arrayReturn the user-visible collection (or array) instance |
| public boolean | Returns: true indicates there are pending, queued, delayed operationsDoes this instance have any "queued" operations? |
| public default boolean | includeInInsert(Object entry, int entryPosition, PersistentCollection<?> collection, PluralAttributeMapping attributeDescriptor)
Whether to include the entry for insertion operations |
| public default boolean | includeInRecreate(Object entry, int i, PersistentCollection<?> collection, PluralAttributeMapping attributeDescriptor)
Whether the given entry should be included in recreation events |
| public void | |
| public void | initializeFromCache(CollectionPersister
The collection persister persister, Object The disassembled cached state disassembled, Object The collection owner owner)Read the state of the collection from a disassembled cached value |
| public void | injectLoadedState(PluralAttributeMapping attributeMapping, List<?> loadingState)
Inject the state loaded for a collection instance. |
| public boolean | Returns: true indicates that the application might have access to the underlying collection/array.Could the application possibly have a direct reference to the underlying collection implementation? |
| public default boolean | Returns: true, ifcollection was provided directly to this
PersistentCollection; false, otherwise.The collection collection)Was |
| public boolean | |
| public default boolean | |
| public boolean | |
| public default boolean | Returns: true if the collection is newly instantiatedIs the collection newly instantiated? |
| public boolean | Returns: true if the row for each element is knownCan each element in the collection be mapped unequivocally to a single row in the database? |
| public boolean | Returns: true if the given snapshot is emptyThe snapshot to check snapshot)Is the snapshot empty? |
| public boolean | Returns: true if the collection is no longer referenced by an ownerIs the collection unreferenced? |
| public boolean | |
| public boolean | Returns: true if the element needs insertingThe collection element to check entry, int The index (for indexed collections) i, Type The type for the element elemType)Do we need to insert this element? |
| public boolean | Returns: true if a change requires a recreate.The collection persister persister)Do we need to completely recreate this collection when it changes? |
| public default boolean | Returns: true if the element needs updatingThe collection element to check entry, int The index (for indexed collections) entryPosition, PluralAttributeMapping The type for the element attributeDescriptor)Do we need to update this element? |
| public boolean | Returns: true if the element needs updatingThe collection element to check entry, int The index (for indexed collections) i, Type The type for the element elemType)Do we need to update this element? |
| public void | postAction()
After flushing, clear any "queued" additions, since the database state is now synchronized with the memory state. |
| public void | preInsert(CollectionPersister
The collection persister persister)Called before inserting rows, to ensure that any surrogate keys are fully generated |
| public Iterator | |
| public default String | |
| public boolean | Returns: false if the collection was already associated with the sessionThe session to associate with session)Associate the collection with the given session. |
| public void | |
| public void | setSnapshot(@Nullable Object
The collection instance key (fk value). key, @Nullable String The collection role role, @Nullable Serializable The snapshot state snapshot)After flushing, re-init snapshot state. |
| public boolean | Returns: true if this was currently associated with the given sessionThe session we are disassociating from. Used for validations. currentSession)Disassociate this collection from the given session. |
| afterInitialize | back to summary |
|---|---|
| public boolean afterInitialize() Called after initialization is complete. Pairs with | |
| afterRowInsert | back to summary |
|---|---|
| public void afterRowInsert(CollectionPersister persister, Object entry, int i) Called after inserting a row, to fetch the natively generated id
| |
| beforeInitialize | back to summary |
|---|---|
| public void beforeInitialize(CollectionPersister persister, int anticipatedSize) Called prior to the initialization of this yet-uninitialized collection. Pairs
with | |
| beginRead | back to summary |
|---|---|
| public void beginRead() Called just before reading any rows from the JDBC result set. Pairs with | |
| clearDirty | back to summary |
|---|---|
| public void clearDirty() Clear the dirty flag, after flushing changes to the database. | |
| dirty | back to summary |
|---|---|
| public void dirty() Mark the collection as dirty | |
| disassemble | back to summary |
|---|---|
| public Object disassemble(CollectionPersister persister) Disassemble the collection to get it ready for the cache
| |
| elementByIndex | back to summary |
|---|---|
| public Object elementByIndex(Object index) Obtain the element os this collection associated with the given index without initializing it | |
| elementExists | back to summary |
|---|---|
| public boolean elementExists(Object element) Determine if the given element belongs to this collection without initializing it | |
| empty | back to summary |
|---|---|
| public boolean empty() Is the collection empty? (don't try to initialize the collection)
| |
| endRead | back to summary |
|---|---|
| public boolean endRead() Called after reading all rows from the JDBC result set. Pairs with
| |
| entries | back to summary |
|---|---|
| public Iterator Iterate all collection entries, during update of the database
| |
| entryExists | back to summary |
|---|---|
| public boolean entryExists(Object entry, int i) Does the given element/entry exist in the collection?
| |
| equalsSnapshot | back to summary |
|---|---|
| public boolean equalsSnapshot(CollectionPersister persister) Does the current state exactly match the snapshot?
| |
| getDeletes | back to summary |
|---|---|
| public Iterator Get all the elements that need deleting
| |
| getElement | back to summary |
|---|---|
| public Object getElement(Object entry) Get the value of the given collection entry. Generally the given entry parameter value will just be returned. Might get a different value for a duplicate entries in a Set. | |
| getIdentifier | back to summary |
|---|---|
| public Object getIdentifier(Object entry, int i) Get the identifier of the given collection entry. This refers to the collection identifier, not the
identifier of the (possibly) entity elements. This is only valid for invocation on the
| |
| getIndex | back to summary |
|---|---|
| public Object getIndex(Object entry, int i, CollectionPersister persister) Get the index of the given collection entry
| |
| getKey | back to summary |
|---|---|
| public Object getKey() Get the current collection key value
| |
| getOrphans | back to summary |
|---|---|
| public Collection get all "orphaned" elements
| |
| getOwner | back to summary |
|---|---|
| public Object getOwner() Get the owning entity. Note that the owner is only set during the flush cycle, and when a new collection wrapper is created while loading an entity.
| |
| getQueuedOrphans | back to summary |
|---|---|
| public Collection Get the "queued" orphans
| |
| getRole | back to summary |
|---|---|
| public String getRole() Get the current role name
| |
| getSize | back to summary |
|---|---|
| public int getSize() Obtain the size of this collection without initializing it | |
| getSnapshot | back to summary |
|---|---|
| public Serializable getSnapshot(CollectionPersister persister) Return a new snapshot of the current state of the collection
| |
| getSnapshotElement | back to summary |
|---|---|
| public Object getSnapshotElement(Object entry, int i) Get the snapshot value of the given collection entry | |
| getStoredSnapshot | back to summary |
|---|---|
| public Serializable getStoredSnapshot() Get the snapshot cached by the collection instance
| |
| getValue | back to summary |
|---|---|
| public Object getValue() Return the user-visible collection (or array) instance
| |
| hasQueuedOperations | back to summary |
|---|---|
| public boolean hasQueuedOperations() Does this instance have any "queued" operations?
| |
| includeInInsert | back to summary |
|---|---|
| public default boolean includeInInsert(Object entry, int entryPosition, PersistentCollection<?> collection, PluralAttributeMapping attributeDescriptor) Whether to include the entry for insertion operations API Note Defined to match signature of | |
| includeInRecreate | back to summary |
|---|---|
| public default boolean includeInRecreate(Object entry, int i, PersistentCollection<?> collection, PluralAttributeMapping attributeDescriptor) Whether the given entry should be included in recreation events API Note Defined to match signature of | |
| initializeEmptyCollection | back to summary |
|---|---|
| public void initializeEmptyCollection(CollectionPersister persister) | |
| initializeFromCache | back to summary |
|---|---|
| public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner) Read the state of the collection from a disassembled cached value
| |
| injectLoadedState | back to summary |
|---|---|
| public void injectLoadedState(PluralAttributeMapping attributeMapping, List<?> loadingState) Inject the state loaded for a collection instance. | |
| isDirectlyAccessible | back to summary |
|---|---|
| public boolean isDirectlyAccessible() Could the application possibly have a direct reference to the underlying collection implementation?
| |
| isDirectlyProvidedCollection | back to summary |
|---|---|
| public default boolean isDirectlyProvidedCollection(Object collection) Was Implementors that can copy elements out of a directly provided collection into the wrapped collection should override this method.
| |
| isDirty | back to summary |
|---|---|
| public boolean isDirty() Is the collection dirty? Note that this is only reliable during the flush cycle, after the collection elements are dirty checked against the snapshot.
| |
| isElementRemoved | back to summary |
|---|---|
| public default boolean isElementRemoved() | |
| isInitializing | back to summary |
|---|---|
| public boolean isInitializing() Is this PersistentCollection in the process of being initialized? | |
| isNewlyInstantiated | back to summary |
|---|---|
| public default boolean isNewlyInstantiated() Is the collection newly instantiated?
| |
| isRowUpdatePossible | back to summary |
|---|---|
| public boolean isRowUpdatePossible() Can each element in the collection be mapped unequivocally to a single row in the database? Generally bags and sets are the only collections that cannot be.
| |
| isSnapshotEmpty | back to summary |
|---|---|
| public boolean isSnapshotEmpty(Serializable snapshot) Is the snapshot empty?
| |
| isUnreferenced | back to summary |
|---|---|
| public boolean isUnreferenced() Is the collection unreferenced?
| |
| isWrapper | back to summary |
|---|---|
| public boolean isWrapper(Object collection) Is this the wrapper for the given collection instance?
| |
| needsInserting | back to summary |
|---|---|
| public boolean needsInserting(Object entry, int i, Type elemType) Do we need to insert this element? | |
| needsRecreate | back to summary |
|---|---|
| public boolean needsRecreate(CollectionPersister persister) Do we need to completely recreate this collection when it changes?
| |
| needsUpdating | back to summary |
|---|---|
| public default boolean needsUpdating(Object entry, int entryPosition, PluralAttributeMapping attributeDescriptor) Do we need to update this element?
| |
| needsUpdating | back to summary |
|---|---|
| public boolean needsUpdating(Object entry, int i, Type elemType) Do we need to update this element? | |
| postAction | back to summary |
|---|---|
| public void postAction() After flushing, clear any "queued" additions, since the database state is now synchronized with the memory state. | |
| preInsert | back to summary |
|---|---|
| public void preInsert(CollectionPersister persister) Called before inserting rows, to ensure that any surrogate keys are fully generated
| |
| queuedAdditionIterator | back to summary |
|---|---|
| public Iterator Iterator over the "queued" additions
| |
| render | back to summary |
|---|---|
| public default String render() Like | |
| setCurrentSession | back to summary |
|---|---|
| public boolean setCurrentSession(SharedSessionContractImplementor session) throws HibernateException Associate the collection with the given session.
| |
| setOwner | back to summary |
|---|---|
| public void setOwner(Object entity) Set the reference to the owning entity
| |
| setSnapshot | back to summary |
|---|---|
| public void setSnapshot(@Nullable Object key, @Nullable String role, @Nullable Serializable snapshot) After flushing, re-init snapshot state. | |
| unsetSession | back to summary |
|---|---|
| public boolean unsetSession(SharedSessionContractImplementor currentSession) Disassociate this collection from the given session.
| |