Package org.hibernate.collection
Class PersistentIdentifierBag
java.lang.Object
org.hibernate.collection.AbstractPersistentCollection
org.hibernate.collection.PersistentIdentifierBag
- All Implemented Interfaces:
Serializable,Iterable,Collection,List,SequencedCollection,PersistentCollection
An IdentifierBag implements "bag" semantics more efficiently than
a regular Bag by adding a synthetic identifier column to the
table. This identifier is unique for all rows in the table, allowing very
efficient updates and deletes. The value of the identifier is never exposed
to the application.
IdentifierBags may not be used for a many-to-one association. Furthermore, there is no reason to use inverse="true".
IdentifierBags may not be used for a many-to-one association. Furthermore, there is no reason to use inverse="true".
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection c) booleanaddAll(Collection c) voidafterRowInsert(CollectionPersister persister, Object entry, int i) Called after inserting a row, to fetch the natively generated idvoidbeforeInitialize(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?booleanequalsSnapshot(CollectionPersister persister) Does the current state exactly match the snapshot?get(int index) getDeletes(CollectionPersister persister, boolean indexIsFormula) Get all the elements that need deletinggetElement(Object entry) Get the value of the given collection entrygetIdentifier(Object entry, int i) Get the index 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 entryintvoidinitializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) Read the state of the collection from a disassembled cached valuebooleanisEmpty()booleanisSnapshotEmpty(Serializable snapshot) Is the snapshot empty?booleanIs this the wrapper for the given underlying collection instance?iterator()intlistIterator(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?voidpreInsert(CollectionPersister persister) Called before inserting rows, to ensure that any surrogate keys are fully generatedreadFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) Read a row from the JDBC result setremove(int index) booleanbooleanbooleanintsize()subList(int fromIndex, int toIndex) Object[]toArray()Object[]Methods inherited from class org.hibernate.collection.AbstractPersistentCollection
afterInitialize, beginRead, clearDirty, dirty, endRead, forceInitialization, getCachedSize, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, initialize, isClearQueueEnabled, isDirectlyAccessible, isDirty, isOperationQueueEnabled, isPutQueueEnabled, isRowUpdatePossible, isUnreferenced, needsRecreate, performQueuedOperations, postAction, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
values
-
identifiers
-
-
Constructor Details
-
PersistentIdentifierBag
-
PersistentIdentifierBag
public PersistentIdentifierBag() -
PersistentIdentifierBag
-
-
Method Details
-
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
-
getIdentifier
Description copied from interface:PersistentCollectionGet the index of the given collection entry- Specified by:
getIdentifierin interfacePersistentCollection- Overrides:
getIdentifierin classAbstractPersistentCollection
-
isWrapper
Description copied from interface:PersistentCollectionIs this the wrapper for the given underlying collection instance?- Specified by:
isWrapperin interfacePersistentCollection
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList
-
iterator
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
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.
-
disassemble
Description copied from interface:PersistentCollectionDisassemble the collection, ready for the cache- Specified by:
disassemblein interfacePersistentCollection- Throws:
HibernateException
-
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
-
entryExists
Description copied from interface:PersistentCollectionDoes an element exist at this entry in the collection?- Specified by:
entryExistsin interfacePersistentCollection
-
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
-
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
-
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
-
needsInserting
Description copied from interface:PersistentCollectionDo we need to insert this element?- Specified by:
needsInsertingin interfacePersistentCollection- Throws:
HibernateException
-
needsUpdating
Description copied from interface:PersistentCollectionDo we need to update this element?- Specified by:
needsUpdatingin interfacePersistentCollection- Throws:
HibernateException
-
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
-
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
-
preInsert
Description copied from class:AbstractPersistentCollectionCalled before inserting rows, to ensure that any surrogate keys are fully generated- Specified by:
preInsertin interfacePersistentCollection- Overrides:
preInsertin classAbstractPersistentCollection- Throws:
HibernateException
-
add
-
addAll
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
remove
-
set
-
subList
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList
-
afterRowInsert
public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException Description copied from class:AbstractPersistentCollectionCalled after inserting a row, to fetch the natively generated id- Specified by:
afterRowInsertin interfacePersistentCollection- Overrides:
afterRowInsertin classAbstractPersistentCollection- Throws:
HibernateException
-