Package org.hibernate.collection.spi
Class PersistentList<E>
- java.lang.Object
-
- org.hibernate.collection.spi.AbstractPersistentCollection<E>
-
- org.hibernate.collection.spi.PersistentList<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,LazyInitializable,PersistentCollection<E>
@Incubating public class PersistentList<E> extends AbstractPersistentCollection<E> implements List<E>
A persistent wrapper for aList. Underlying collection is anArrayList.- 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 Modifier and Type Class Description protected classPersistentList.SimpleAdd-
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 protected List<E>list-
Fields inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
elementRemoved, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description PersistentList()Constructs a PersistentList.PersistentList(SharedSessionContractImplementor session)Constructs a PersistentList.PersistentList(SharedSessionContractImplementor session, List<E> list)Constructs a PersistentList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E value)booleanadd(E object)booleanaddAll(int index, Collection<? extends E> coll)booleanaddAll(Collection<? extends E> values)voidclear()booleancontains(Object object)booleancontainsAll(Collection<?> coll)Objectdisassemble(CollectionPersister persister)Disassemble the collection to get it ready for the cachebooleanempty()Is the collection empty? (don't try to initialize the collection)Iterator<E>entries(CollectionPersister persister)Iterate all collection entries, during update of the databasebooleanentryExists(Object entry, int i)Does the given element/entry exist in the collection?booleanequals(Object other)booleanequalsSnapshot(CollectionPersister persister)Does the current state exactly match the snapshot?Eget(int index)Iterator<?>getDeletes(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 entryCollection<E>getOrphans(Serializable snapshot, String entityName)get all "orphaned" elementsprotected List<E>getRawList()SerializablegetSnapshot(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 entryinthashCode()intindexOf(Object value)voidinitializeEmptyCollection(CollectionPersister persister)voidinitializeFromCache(CollectionPersister persister, Object disassembled, Object owner)Read the state of the collection from a disassembled cached valuevoidinjectLoadedState(PluralAttributeMapping attributeMapping, List<?> loadingStateList)Inject the state loaded for a collection instance.booleanisEmpty()booleanisSnapshotEmpty(Serializable snapshot)Is the snapshot empty?booleanisWrapper(Object collection)Is this the wrapper for the given collection instance?Iterator<E>iterator()intlastIndexOf(Object value)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)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?Eremove(int index)booleanremove(Object value)booleanremoveAll(Collection<?> coll)booleanretainAll(Collection<?> coll)Eset(int index, E value)intsize()List<E>subList(int from, int to)Object[]toArray()<A> A[]toArray(A[] array)StringtoString()-
Methods inherited from class org.hibernate.collection.spi.AbstractPersistentCollection
afterInitialize, afterRowInsert, beforeInitialize, beginRead, clearDirty, clearOperationQueue, dirty, elementByIndex, elementExists, endRead, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSize, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, identityRemove, initialize, isClearQueueEnabled, isConnectedToSession, isDirectlyAccessible, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Methods inherited from interface org.hibernate.collection.spi.PersistentCollection
includeInInsert, includeInRecreate, isDirectlyProvidedCollection, isNewlyInstantiated, needsUpdating, render
-
-
-
-
Constructor Detail
-
PersistentList
public PersistentList()
Constructs a PersistentList. This form needed for SOAP libraries, etc
-
PersistentList
public PersistentList(SharedSessionContractImplementor session)
Constructs a PersistentList.- Parameters:
session- The session
-
PersistentList
public PersistentList(SharedSessionContractImplementor session, List<E> list)
Constructs a PersistentList.- Parameters:
session- The sessionlist- The raw list
-
-
Method Detail
-
getSnapshot
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException
Description copied from interface:PersistentCollectionReturn a new snapshot of the current state of the collection- Specified by:
getSnapshotin interfacePersistentCollection<E>- Parameters:
persister- The collection persister- Returns:
- The snapshot
- Throws:
HibernateException
-
getOrphans
public Collection<E> getOrphans(Serializable snapshot, String entityName) throws HibernateException
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)
- Specified by:
initializeEmptyCollectionin interfacePersistentCollection<E>
-
equalsSnapshot
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException
Description copied from interface:PersistentCollectionDoes the current state exactly match the snapshot?- Specified by:
equalsSnapshotin interfacePersistentCollection<E>- Parameters:
persister- The collection persister- Returns:
trueif the current state and the snapshot state match.- Throws:
HibernateException
-
isSnapshotEmpty
public boolean isSnapshotEmpty(Serializable snapshot)
Description copied from interface:PersistentCollectionIs the snapshot empty?- Specified by:
isSnapshotEmptyin interfacePersistentCollection<E>- Parameters:
snapshot- The snapshot to check- Returns:
trueif the given snapshot is empty
-
initializeFromCache
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner) throws HibernateException
Description copied from interface:PersistentCollectionRead the state of the collection from a disassembled cached value- Specified by:
initializeFromCachein interfacePersistentCollection<E>- Parameters:
persister- The collection persisterdisassembled- The disassembled cached stateowner- The collection owner- Throws:
HibernateException
-
injectLoadedState
public void injectLoadedState(PluralAttributeMapping attributeMapping, List<?> loadingStateList)
Description copied from interface:PersistentCollectionInject the state loaded for a collection instance.- Specified by:
injectLoadedStatein interfacePersistentCollection<E>
-
isWrapper
public boolean isWrapper(Object collection)
Description copied from interface:PersistentCollectionIs this the wrapper for the given collection instance?- Specified by:
isWrapperin interfacePersistentCollection<E>- Parameters:
collection- The collection to check whether this is wrapping it- Returns:
trueif this is a wrapper around that given collection instance.
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object object)
-
toArray
public Object[] toArray()
-
toArray
public <A> A[] toArray(A[] array)
-
add
public boolean add(E object)
-
remove
public boolean remove(Object value)
-
containsAll
public boolean containsAll(Collection<?> coll)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
addAll
public boolean addAll(Collection<? extends E> values)
-
addAll
public boolean addAll(int index, Collection<? extends E> coll)
-
removeAll
public boolean removeAll(Collection<?> coll)
-
retainAll
public boolean retainAll(Collection<?> coll)
-
clear
public void clear()
-
lastIndexOf
public int lastIndexOf(Object value)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>
-
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<E> entries(CollectionPersister persister)
Description copied from interface:PersistentCollectionIterate all collection entries, during update of the database- Specified by:
entriesin interfacePersistentCollection<E>- Parameters:
persister- The collection persister.- Returns:
- The iterator
-
disassemble
public Object disassemble(CollectionPersister persister) throws HibernateException
Description copied from interface:PersistentCollectionDisassemble the collection to get it ready for the cache- Specified by:
disassemblein interfacePersistentCollection<E>- Parameters:
persister- The collection persister- Returns:
- The disassembled state
- Throws:
HibernateException
-
getDeletes
public Iterator<?> getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException
Description copied from interface:PersistentCollectionGet all the elements that need deleting- Specified by:
getDeletesin interfacePersistentCollection<E>- 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) throws HibernateException
Description copied from interface:PersistentCollectionDo we need to insert this element?- Specified by:
needsInsertingin interfacePersistentCollection<E>- 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) throws HibernateException
Description copied from interface:PersistentCollectionDo we need to update this element?- Specified by:
needsUpdatingin interfacePersistentCollection<E>- 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- Specified by:
getIndexin interfacePersistentCollection<E>- 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.- Specified by:
getElementin interfacePersistentCollection<E>- 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- Specified by:
getSnapshotElementin interfacePersistentCollection<E>- Parameters:
entry- The entryi- The index- Returns:
- The snapshot state for that element
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
entryExists
public boolean entryExists(Object entry, int i)
Description copied from interface:PersistentCollectionDoes the given element/entry exist in the collection?- Specified by:
entryExistsin interfacePersistentCollection<E>- Parameters:
entry- The object to check if it exists as a collection elementi- Unused- Returns:
trueif the given entry is a collection element
-
-