Package org.hibernate.collection
Class PersistentBag
java.lang.Object
org.hibernate.collection.AbstractPersistentCollection
org.hibernate.collection.PersistentBag
- All Implemented Interfaces:
Serializable,Iterable,Collection,List,SequencedCollection,PersistentCollection
An unordered, unkeyed collection that can contain the same element
multiple times. The Java collections API, curiously, has no Bag.
Most developers seem to use Lists to represent bag semantics,
so Hibernate follows this practice.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.collection.AbstractPersistentCollection
AbstractPersistentCollection.DelayedOperation -
Field Summary
FieldsFields inherited from class org.hibernate.collection.AbstractPersistentCollection
UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionPersistentBag(SessionImplementor session) PersistentBag(SessionImplementor session, Collection coll) -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int i, Collection c) booleanaddAll(Collection values) voidbeforeInitialize(CollectionPersister persister, int anticipatedSize) Called before any elements are read into the collection, allowing appropriate initializations to occur.voidclear()booleanbooleandisassemble(CollectionPersister persister) Disassemble the collection, ready for the cachebooleanempty()Is the initialized collection empty?entries(CollectionPersister persister) Iterate all collection entries, during update of the databasebooleanentryExists(Object entry, int i) Does an element exist at this entry in the collection?booleanBag does not respect the collection API and do an JVM instance comparison to do the equals.booleanequalsSnapshot(CollectionPersister persister) Does the current state exactly match the snapshot?get(int i) getDeletes(CollectionPersister persister, boolean indexIsFormula) Get all the elements that need deletinggetElement(Object entry) Get the value of the given collection entrygetIndex(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 entryinthashCode()intvoidinitializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) Read the state of the collection from a disassembled cached valuebooleanisEmpty()booleanbooleanisSnapshotEmpty(Serializable snapshot) Is the snapshot empty?booleanIs this the wrapper for the given underlying collection instance?iterator()intlistIterator(int i) booleanneedsInserting(Object entry, int i, Type elemType) Do we need to insert this element?booleanneedsRecreate(CollectionPersister persister) Do we need to completely recreate this collection when it changes?booleanneedsUpdating(Object entry, int i, Type elemType) Do we need to update this element?intreadFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) Read a row from the JDBC result setremove(int i) booleanbooleanbooleanintsize()subList(int start, int end) Object[]toArray()Object[]toString()Methods inherited from class org.hibernate.collection.AbstractPersistentCollection
afterInitialize, afterRowInsert, beginRead, clearDirty, dirty, endRead, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, initialize, isClearQueueEnabled, isDirectlyAccessible, isDirty, isOperationQueueEnabled, isPutQueueEnabled, isUnreferenced, performQueuedOperations, postAction, preInsert, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, writeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
bag
-
-
Constructor Details
-
PersistentBag
-
PersistentBag
-
PersistentBag
public PersistentBag()
-
-
Method Details
-
isWrapper
Description copied from interface:PersistentCollectionIs this the wrapper for the given underlying collection instance?- Specified by:
isWrapperin interfacePersistentCollection
-
empty
public boolean empty()Description copied from class:AbstractPersistentCollectionIs the initialized collection empty?- Specified by:
emptyin interfacePersistentCollection- Specified by:
emptyin classAbstractPersistentCollection
-
entries
Description copied from interface:PersistentCollectionIterate all collection entries, during update of the database- Specified by:
entriesin interfacePersistentCollection
-
readFrom
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException Description copied from interface:PersistentCollectionRead a row from the JDBC result set- Specified by:
readFromin interfacePersistentCollection- Throws:
HibernateExceptionSQLException
-
beforeInitialize
Description copied from interface:PersistentCollectionCalled before any elements are read into the collection, allowing appropriate initializations to occur.- Specified by:
beforeInitializein interfacePersistentCollection- Parameters:
persister- The underlying collection persister.anticipatedSize- The anticipated size of the collection after initilization is complete.
-
equalsSnapshot
Description copied from interface:PersistentCollectionDoes the current state exactly match the snapshot?- Specified by:
equalsSnapshotin interfacePersistentCollection- Throws:
HibernateException
-
isSnapshotEmpty
Description copied from interface:PersistentCollectionIs the snapshot empty?- Specified by:
isSnapshotEmptyin interfacePersistentCollection
-
getSnapshot
Description copied from interface:PersistentCollectionReturn a new snapshot of the current state of the collection- Specified by:
getSnapshotin interfacePersistentCollection- Throws:
HibernateException
-
getOrphans
Description copied from class:AbstractPersistentCollectionget all "orphaned" elements- Specified by:
getOrphansin interfacePersistentCollection- Specified by:
getOrphansin classAbstractPersistentCollection- Throws:
HibernateException
-
disassemble
Description copied from interface:PersistentCollectionDisassemble the collection, ready for the cache- Specified by:
disassemblein interfacePersistentCollection- Throws:
HibernateException
-
initializeFromCache
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException Description copied from interface:PersistentCollectionRead the state of the collection from a disassembled cached value- Specified by:
initializeFromCachein interfacePersistentCollection- Throws:
HibernateException
-
needsRecreate
Description copied from class:AbstractPersistentCollectionDo we need to completely recreate this collection when it changes?- Specified by:
needsRecreatein interfacePersistentCollection- Overrides:
needsRecreatein classAbstractPersistentCollection
-
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- Throws:
HibernateException
-
needsInserting
Description copied from interface:PersistentCollectionDo we need to insert this element?- Specified by:
needsInsertingin interfacePersistentCollection- Throws:
HibernateException
-
isRowUpdatePossible
public boolean isRowUpdatePossible()- Specified by:
isRowUpdatePossiblein interfacePersistentCollection- Overrides:
isRowUpdatePossiblein classAbstractPersistentCollection
-
needsUpdating
Description copied from interface:PersistentCollectionDo we need to update this element?- Specified by:
needsUpdatingin interfacePersistentCollection
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- See Also:
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList- See Also:
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList- See Also:
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList- See Also:
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList- See Also:
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList- See Also:
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList- See Also:
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList- See Also:
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- See Also:
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList- See Also:
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList- See Also:
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList- See Also:
-
getIndex
Description copied from interface:PersistentCollectionGet the index of the given collection entry- Specified by:
getIndexin interfacePersistentCollection- Parameters:
persister- it was more elegant before we added this...
-
getElement
Description copied from interface:PersistentCollectionGet the value of the given collection entry- Specified by:
getElementin interfacePersistentCollection
-
getSnapshotElement
Description copied from interface:PersistentCollectionGet the snapshot value of the given collection entry- Specified by:
getSnapshotElementin interfacePersistentCollection
-
occurrences
-
add
-
addAll
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList- See Also:
-
listIterator
- Specified by:
listIteratorin interfaceList- See Also:
-
listIterator
- Specified by:
listIteratorin interfaceList- See Also:
-
remove
-
set
-
subList
-
toString
-
entryExists
Description copied from interface:PersistentCollectionDoes an element exist at this entry in the collection?- Specified by:
entryExistsin interfacePersistentCollection
-
equals
Bag does not respect the collection API and do an JVM instance comparison to do the equals. The semantic is broken not to have to initialize a collection for a simple equals() operation. -
hashCode
public int hashCode()
-