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>
@Incubatingpublic classPersistentArrayHolder<E>extendsAbstractPersistentCollection<E>
A dummy collection wrapper for an array. Lazy initialization isnot supported. The use of arrays to represent persistent collections in Hibernate is discouraged.- See Also:
- Serialized Form
- 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
Fields Modifier and Type Field Description protectedObjectarrayFields inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
elementRemoved,UNKNOWN
Constructor Summary
Constructors Constructor Description PersistentArrayHolder(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectdisassemble(CollectionPersister persister)Disassemble the collection to get it ready for the cacheIteratorelements()Get an iterator over the array elementsbooleanempty()Is the collection empty? (don't try to initialize the collection)booleanendRead()Called after reading all rows from the JDBC result set.Iteratorentries(CollectionPersister persister)Iterate all collection entries, during update of the databasebooleanentryExists(Object entry, int i)Does the given element/entry exist in the collection?booleanequalsSnapshot(CollectionPersister persister)Does the current state exactly match the snapshot?ObjectgetArray()IteratorgetDeletes(CollectionPersister persister, boolean indexIsFormula)Get all the elements that need deletingObjectgetElement(Object entry)Get the value of the given collection entry.ObjectgetIndex(Object entry, int i,CollectionPersister persister)Get the index of the given collection entryCollectiongetOrphans(Serializable snapshot,String entityName)get all "orphaned" elementsSerializablegetSnapshot(CollectionPersister persister)Return a new snapshot of the current state of the collectionObjectgetSnapshotElement(Object entry, int i)Get the snapshot value of the given collection entryObjectgetValue()Return the user-visible collection (or array) instancevoidinitializeEmptyCollection(CollectionPersister persister)voidinitializeFromCache(CollectionPersister persister,Object disassembled,Object owner)Read the state of the collection from a disassembled cached valuevoidinjectLoadedState(PluralAttributeMapping attributeMapping,List loadingState)Inject the state loaded for a collection instance.booleanisDirectlyAccessible()Could the application possibly have a direct reference to the underlying collection implementation?booleanisSnapshotEmpty(Serializable snapshot)Is the snapshot empty?booleanisWrapper(Object collection)Is this the wrapper for the given collection instance?booleanneedsInserting(Object entry, int i,Type elemType)Do we need to insert this element?booleanneedsUpdating(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 Detail
array
protected Object array
Constructor Detail
PersistentArrayHolder
public PersistentArrayHolder(SharedSessionContractImplementor session,Object array)
Constructs a PersistentCollection instance for holding an array.- Parameters:
session- The sessionarray- The array (the persistent "collection").
PersistentArrayHolder
public PersistentArrayHolder(SharedSessionContractImplementor session,CollectionPersister persister)
Constructs a PersistentCollection instance for holding an array.- Parameters:
session- The sessionpersister- The persister for the array
Method Detail
getSnapshot
public Serializable getSnapshot(CollectionPersister persister) throwsHibernateException
Description copied from interface:PersistentCollectionReturn a new snapshot of the current state of the collection- Parameters:
persister- The collection persister- Returns:
- The snapshot
- Throws:
HibernateException
isSnapshotEmpty
public boolean isSnapshotEmpty(Serializable snapshot)
Description copied from interface:PersistentCollectionIs the snapshot empty?- Parameters:
snapshot- The snapshot to check- Returns:
trueif the given snapshot is empty
getOrphans
public Collection getOrphans(Serializable snapshot,String entityName) throwsHibernateException
Description copied from interface:PersistentCollectionget all "orphaned" elements- Specified by:
getOrphansin interfacePersistentCollection<E>- Specified by:
getOrphansin 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
public void initializeEmptyCollection(CollectionPersister persister)
injectLoadedState
public void injectLoadedState(PluralAttributeMapping attributeMapping,List loadingState)
Description copied from interface:PersistentCollectionInject the state loaded for a collection instance.
getArray
public Object getArray()
isWrapper
public boolean isWrapper(Object collection)
Description copied from interface:PersistentCollectionIs this the wrapper for the given collection instance?- Parameters:
collection- The collection to check whether this is wrapping it- Returns:
trueif this is a wrapper around that given collection instance.
equalsSnapshot
public boolean equalsSnapshot(CollectionPersister persister) throwsHibernateException
Description copied from interface:PersistentCollectionDoes the current state exactly match the snapshot?- Parameters:
persister- The collection persister- Returns:
trueif the current state and the snapshot state match.- Throws:
HibernateException
elements
public Iterator elements()
Get an iterator over the array elements- Returns:
- The iterator
empty
public boolean empty()
Description copied from interface:PersistentCollectionIs the collection empty? (don't try to initialize the collection)- Specified by:
emptyin interfacePersistentCollection<E>- Specified by:
emptyin classAbstractPersistentCollection<E>- Returns:
falseif the collection is non-empty;trueotherwise.
entries
public Iterator entries(CollectionPersister persister)
Description copied from interface:PersistentCollectionIterate all collection entries, during update of the database- Parameters:
persister- The collection persister.- Returns:
- The iterator
endRead
public boolean endRead()
Description copied from interface:PersistentCollectionCalled after reading all rows from the JDBC result set. Pairs withPersistentCollection.beginRead()- Specified by:
endReadin interfacePersistentCollection<E>- Overrides:
endReadin classAbstractPersistentCollection<E>- See Also:
PersistentCollection.injectLoadedState(org.hibernate.metamodel.mapping.PluralAttributeMapping, java.util.List<?>)
isDirectlyAccessible
public boolean isDirectlyAccessible()
Description copied from interface:PersistentCollectionCould the application possibly have a direct reference to the underlying collection implementation?- Specified by:
isDirectlyAccessiblein interfacePersistentCollection<E>- Overrides:
isDirectlyAccessiblein classAbstractPersistentCollection<E>- Returns:
trueindicates that the application might have access to the underlying collection/array.
initializeFromCache
public void initializeFromCache(CollectionPersister persister,Object disassembled,Object owner) throwsHibernateException
Description copied from interface:PersistentCollectionRead 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
public Object disassemble(CollectionPersister persister) throwsHibernateException
Description copied from interface:PersistentCollectionDisassemble the collection to get it ready for the cache- Parameters:
persister- The collection persister- Returns:
- The disassembled state
- Throws:
HibernateException
getValue
public Object getValue()
Description copied from interface:PersistentCollectionReturn the user-visible collection (or array) instance- Specified by:
getValuein interfacePersistentCollection<E>- Overrides:
getValuein classAbstractPersistentCollection<E>- Returns:
- The underlying collection/array
getDeletes
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throwsHibernateException
Description copied from interface:PersistentCollectionGet 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
public boolean needsInserting(Object entry, int i,Type elemType) throwsHibernateException
Description copied from interface:PersistentCollectionDo 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:
trueif the element needs inserting- Throws:
HibernateException
needsUpdating
public boolean needsUpdating(Object entry, int i,Type elemType) throwsHibernateException
Description copied from interface:PersistentCollectionDo 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:
trueif the element needs updating- Throws:
HibernateException
getIndex
public Object getIndex(Object entry, int i,CollectionPersister persister)
Description copied from interface:PersistentCollectionGet 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
public Object getElement(Object entry)
Description copied from interface:PersistentCollectionGet 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
public Object getSnapshotElement(Object entry, int i)
Description copied from interface:PersistentCollectionGet the snapshot value of the given collection entry- Parameters:
entry- The entryi- The index- Returns:
- The snapshot state for that element
entryExists
public boolean entryExists(Object entry, int i)
Description copied from interface:PersistentCollectionDoes the given element/entry exist in the collection?- Parameters:
entry- The object to check if it exists as a collection elementi- Unused- Returns:
trueif the given entry is a collection element