Package org.hibernate.collection.spi
Class PersistentArrayHolder<E>
java.lang.Object
org.hibernate.collection.spi.AbstractPersistentCollection<E>
org.hibernate.collection.spi.PersistentArrayHolder<E>
- All Implemented Interfaces:
Serializable
,LazyInitializable
,PersistentCollection<E>
A dummy collection wrapper for an array. Lazy initialization is
not supported. The use of arrays to represent persistent
collections in Hibernate is discouraged.
- See Also:
- API Note:
- Incubating in terms of making this non-internal. These contracts will be getting cleaned up in following releases.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
AbstractPersistentCollection.AbstractValueDelayedOperation, AbstractPersistentCollection.DelayedOperation<E>, AbstractPersistentCollection.IteratorProxy<E>, AbstractPersistentCollection.LazyInitializationWork<T>, AbstractPersistentCollection.ListIteratorProxy, AbstractPersistentCollection.ListProxy, AbstractPersistentCollection.SetProxy<E>, AbstractPersistentCollection.ValueDelayedOperation<E>
-
Field Summary
FieldsFields inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
elementRemoved, UNKNOWN
-
Constructor Summary
ConstructorsConstructorDescriptionPersistentArrayHolder
(SharedSessionContractImplementor session, Object array) Constructs a PersistentCollection instance for holding an array.PersistentArrayHolder
(SharedSessionContractImplementor session, CollectionPersister persister) Constructs a PersistentCollection instance for holding an array. -
Method Summary
Modifier and TypeMethodDescriptiondisassemble
(CollectionPersister persister) Disassemble the collection to get it ready for the cacheelements()
Get an iterator over the array elementsboolean
empty()
Is the collection empty? (don't try to initialize the collection)boolean
endRead()
Called after reading all rows from the JDBC result set.entries
(CollectionPersister persister) Iterate all collection entries, during update of the databaseboolean
entryExists
(Object entry, int i) Does the given element/entry exist in the collection?boolean
equalsSnapshot
(CollectionPersister persister) Does the current state exactly match the snapshot?getArray()
getDeletes
(CollectionPersister persister, boolean indexIsFormula) Get all the elements that need deletinggetElement
(Object entry) Get the value of the given collection entry.getIndex
(Object entry, int i, CollectionPersister persister) Get the index of the given collection entrygetOrphans
(Serializable snapshot, String entityName) get all "orphaned" elementsgetSnapshot
(CollectionPersister persister) Return a new snapshot of the current state of the collectiongetSnapshotElement
(Object entry, int i) Get the snapshot value of the given collection entrygetValue()
Return the user-visible collection (or array) instancevoid
initializeEmptyCollection
(CollectionPersister persister) void
initializeFromCache
(CollectionPersister persister, Object disassembled, Object owner) Read the state of the collection from a disassembled cached valuevoid
injectLoadedState
(PluralAttributeMapping attributeMapping, List loadingState) Inject the state loaded for a collection instance.boolean
Could the application possibly have a direct reference to the underlying collection implementation?boolean
isSnapshotEmpty
(Serializable snapshot) Is the snapshot empty?boolean
Is this the wrapper for the given collection instance?boolean
needsInserting
(Object entry, int i, Type elemType) Do we need to insert this element?boolean
needsUpdating
(Object entry, int i, Type elemType) Do we need to update this element?Methods inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
afterInitialize, afterRowInsert, beforeInitialize, beginRead, clearDirty, clearOperationQueue, dirty, elementByIndex, elementExists, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSize, getSnapshot, getStoredSnapshot, hasQueuedOperations, identityRemove, initialize, isClearQueueEnabled, isConnectedToSession, isDirty, isElementRemoved, isInitialized, isInitializing, isInverseCollection, isInverseCollectionNoOrphanDelete, isInverseOneToManyOrNoOrphanDelete, isOperationQueueEnabled, isPutQueueEnabled, isRowUpdatePossible, isUnreferenced, needsRecreate, performQueuedOperations, postAction, preInsert, prepareForPossibleLoadingOutsideTransaction, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, replaceQueuedOperationValues, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hibernate.collection.spi.PersistentCollection
includeInInsert, includeInRecreate, isDirectlyProvidedCollection, isNewlyInstantiated, needsUpdating, render
-
Field Details
-
array
-
-
Constructor Details
-
Method Details
-
getSnapshot
Description copied from interface:PersistentCollection
Return a new snapshot of the current state of the collection- Parameters:
persister
- The collection persister- Returns:
- The snapshot
- Throws:
HibernateException
-
isSnapshotEmpty
Description copied from interface:PersistentCollection
Is the snapshot empty?- Parameters:
snapshot
- The snapshot to check- Returns:
true
if the given snapshot is empty
-
getOrphans
Description copied from interface:PersistentCollection
get all "orphaned" elements- Specified by:
getOrphans
in interfacePersistentCollection<E>
- Specified by:
getOrphans
in classAbstractPersistentCollection<E>
- Parameters:
snapshot
- The snapshot stateentityName
- The name of the entity that are the elements of the collection- Returns:
- The orphans
- Throws:
HibernateException
-
initializeEmptyCollection
-
injectLoadedState
Description copied from interface:PersistentCollection
Inject the state loaded for a collection instance. -
getArray
-
isWrapper
Description copied from interface:PersistentCollection
Is this the wrapper for the given collection instance?- Parameters:
collection
- The collection to check whether this is wrapping it- Returns:
true
if this is a wrapper around that given collection instance.
-
equalsSnapshot
Description copied from interface:PersistentCollection
Does the current state exactly match the snapshot?- Parameters:
persister
- The collection persister- Returns:
true
if the current state and the snapshot state match.- Throws:
HibernateException
-
elements
Get an iterator over the array elements- Returns:
- The iterator
-
empty
public boolean empty()Description copied from interface:PersistentCollection
Is the collection empty? (don't try to initialize the collection)- Specified by:
empty
in interfacePersistentCollection<E>
- Specified by:
empty
in classAbstractPersistentCollection<E>
- Returns:
false
if the collection is non-empty;true
otherwise.
-
entries
Description copied from interface:PersistentCollection
Iterate all collection entries, during update of the database- Parameters:
persister
- The collection persister.- Returns:
- The iterator
-
endRead
public boolean endRead()Description copied from interface:PersistentCollection
Called after reading all rows from the JDBC result set. Pairs withPersistentCollection.beginRead()
- Specified by:
endRead
in interfacePersistentCollection<E>
- Overrides:
endRead
in classAbstractPersistentCollection<E>
- See Also:
-
isDirectlyAccessible
public boolean isDirectlyAccessible()Description copied from interface:PersistentCollection
Could the application possibly have a direct reference to the underlying collection implementation?- Specified by:
isDirectlyAccessible
in interfacePersistentCollection<E>
- Overrides:
isDirectlyAccessible
in classAbstractPersistentCollection<E>
- Returns:
true
indicates that the application might have access to the underlying collection/array.
-
initializeFromCache
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner) throws HibernateException Description copied from interface:PersistentCollection
Read the state of the collection from a disassembled cached value- Parameters:
persister
- The collection persisterdisassembled
- The disassembled cached stateowner
- The collection owner- Throws:
HibernateException
-
disassemble
Description copied from interface:PersistentCollection
Disassemble the collection to get it ready for the cache- Parameters:
persister
- The collection persister- Returns:
- The disassembled state
- Throws:
HibernateException
-
getValue
Description copied from interface:PersistentCollection
Return the user-visible collection (or array) instance- Specified by:
getValue
in interfacePersistentCollection<E>
- Overrides:
getValue
in classAbstractPersistentCollection<E>
- Returns:
- The underlying collection/array
-
getDeletes
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException Description copied from interface:PersistentCollection
Get all the elements that need deleting- Parameters:
persister
- The collection persisterindexIsFormula
- For indexed collections, tells whether the index is a formula (calculated value) mapping- Returns:
- An iterator over the elements to delete
- Throws:
HibernateException
-
needsInserting
Description copied from interface:PersistentCollection
Do we need to insert this element?- Parameters:
entry
- The collection element to checki
- The index (for indexed collections)elemType
- The type for the element- Returns:
true
if the element needs inserting- Throws:
HibernateException
-
needsUpdating
Description copied from interface:PersistentCollection
Do we need to update this element?- Parameters:
entry
- The collection element to checki
- The index (for indexed collections)elemType
- The type for the element- Returns:
true
if the element needs updating- Throws:
HibernateException
-
getIndex
Description copied from interface:PersistentCollection
Get the index of the given collection entry- Parameters:
entry
- The collection entry/elementi
- The assumed indexpersister
- it was more elegant before we added this...- Returns:
- The index value
-
getElement
Description copied from interface:PersistentCollection
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.- Parameters:
entry
- The object instance for which to get the collection element instance.- Returns:
- The corresponding object that is part of the collection elements.
-
getSnapshotElement
Description copied from interface:PersistentCollection
Get the snapshot value of the given collection entry- Parameters:
entry
- The entryi
- The index- Returns:
- The snapshot state for that element
-
entryExists
Description copied from interface:PersistentCollection
Does the given element/entry exist in the collection?- Parameters:
entry
- The object to check if it exists as a collection elementi
- Unused- Returns:
true
if the given entry is a collection element
-