Top Description Fields Constructors Methods
org.hibernate.collection.internal

public Class PersistentIdentifierBag

extends AbstractPersistentCollection
implements List
Class Inheritance
All Implemented Interfaces
java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Imports
java.io.Serializable, java.sql.ResultSet, .SQLException, java.util.ArrayList, .Collection, .HashMap, .Iterator, .List, .ListIterator, .Map, org.hibernate.HibernateException, org.hibernate.engine.spi.SessionImplementor, .SharedSessionContractImplementor, org.hibernate.loader.CollectionAliases, org.hibernate.persister.collection.CollectionPersister, org.hibernate.type.Type

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".
Author
Gavin King

Field Summary

Modifier and TypeField and Description
protected Map<Integer, Object>
private Collection<E>
protected List<Object>
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
elementRemovedUNKNOWN

Constructor Summary

AccessConstructor and Description
public
PersistentIdentifierBag()

Constructs a PersistentIdentifierBag.

public
PersistentIdentifierBag(SharedSessionContractImplementor
The session
session
)

Constructs a PersistentIdentifierBag.

public
PersistentIdentifierBag(SessionImplementor
The session
session
)

Constructs a PersistentIdentifierBag.
public
PersistentIdentifierBag(SharedSessionContractImplementor
The session
session
,
Collection<E>
The base elements
coll
)

Constructs a PersistentIdentifierBag.

public
PersistentIdentifierBag(SessionImplementor
The session
session
,
Collection<E>
The base elements
coll
)

Constructs a PersistentIdentifierBag.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(Object
element to be appended to this list
o
)

Implements java.util.List.add.

Appends the specified element to the end of this list (optional operation).
public void
add(int
index at which the specified element is to be inserted
index
,
Object
element to be inserted
element
)

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).
public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
public boolean
addAll(Collection<E>
collection containing elements to be added to this list
c
)

Implements java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).
public void
afterRowInsert(CollectionPersister
The collection persister
persister
,
Object
The collection element just inserted
entry
,
int
The element position/index
i
)

Overrides org.hibernate.collection.internal.AbstractPersistentCollection.afterRowInsert.

Implements org.hibernate.collection.spi.PersistentCollection.afterRowInsert.

Called after inserting a row, to fetch the natively generated id
private void
beforeAdd(int index)

public void
beforeInitialize(CollectionPersister
The underlying collection persister.
persister
,
int
The anticipated size of the collection after initialization is complete.
anticipatedSize
)

Implements org.hibernate.collection.spi.PersistentCollection.beforeInitialize.

Called before any elements are read into the collection, allowing appropriate initializations to occur.
private void
beforeRemove(int index)

public void
clear()

Implements java.util.List.clear.

Removes all of the elements from this list (optional operation).
public boolean
contains(Object
element whose presence in this list is to be tested
o
)

Implements java.util.List.contains.

Returns true if this list contains the specified element.
public boolean
containsAll(Collection<E>
collection to be checked for containment in this list
c
)

Implements java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.
public Serializable
disassemble(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.disassemble.

Disassemble the collection to get it ready for the cache
public boolean
public Iterator<E>
entries(CollectionPersister
The collection persister.
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.entries.

Iterate all collection entries, during update of the database
public boolean
entryExists(Object
The object to check if it exists as a collection element
entry
,
int
Unused
i
)

Implements org.hibernate.collection.spi.PersistentCollection.entryExists.

Does the given element/entry exist in the collection?
public boolean
equalsSnapshot(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.equalsSnapshot.

Does the current state exactly match the snapshot?
public Object
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.
public Iterator<E>
getDeletes(CollectionPersister
The collection persister
persister
,
boolean
For indexed collections, tells whether the index is a formula (calculated value) mapping
indexIsFormula
)

Implements org.hibernate.collection.spi.PersistentCollection.getDeletes.

Get all the elements that need deleting
public Object
getElement(Object
The object instance for which to get the collection element instance.
entry
)

Implements org.hibernate.collection.spi.PersistentCollection.getElement.

Get the value of the given collection entry.
public Object
getIdentifier(Object
The collection entry/element
entry
,
int
The assumed identifier (?)
i
)

Overrides org.hibernate.collection.internal.AbstractPersistentCollection.getIdentifier.

Implements org.hibernate.collection.spi.PersistentCollection.getIdentifier.

Get the identifier of the given collection entry.
public Object
getIndex(Object
The collection entry/element
entry
,
int
The assumed index
i
,
CollectionPersister
it was more elegant before we added this...
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.getIndex.

Get the index of the given collection entry
public Collection<E>
getOrphans(Serializable
The snapshot state
snapshot
,
String
The name of the entity that are the elements of the collection
entityName
)

Implements abstract org.hibernate.collection.internal.AbstractPersistentCollection.getOrphans.

Implements org.hibernate.collection.spi.PersistentCollection.getOrphans.

get all "orphaned" elements
public Serializable
getSnapshot(CollectionPersister
The collection persister
persister
)

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshot.

Return a new snapshot of the current state of the collection
public Object
getSnapshotElement(Object
The entry
entry
,
int
The index
i
)

Implements org.hibernate.collection.spi.PersistentCollection.getSnapshotElement.

Get the snapshot value of the given collection entry
public int
indexOf(Object
element to search for
o
)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
public void
initializeFromCache(CollectionPersister
The collection persister
persister
,
Serializable
The disassembled cached state
disassembled
,
Object
The collection owner
owner
)

Implements org.hibernate.collection.spi.PersistentCollection.initializeFromCache.

Read the state of the collection from a disassembled cached value
public boolean
isDirectlyProvidedCollection(Object
The collection
collection
)

Overrides default org.hibernate.collection.spi.PersistentCollection.isDirectlyProvidedCollection.

Was collection provided directly to this PersistentCollection (i.e., provided as an argument to a constructor)?
public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.
public boolean
isSnapshotEmpty(Serializable
The snapshot to check
snapshot
)

Implements org.hibernate.collection.spi.PersistentCollection.isSnapshotEmpty.

Is the snapshot empty?
public boolean
isWrapper(Object
The collection to check whether this is wrapping it
collection
)

Implements org.hibernate.collection.spi.PersistentCollection.isWrapper.

Is this the wrapper for the given collection instance?
public Iterator<E>
iterator()

Implements java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.
public int
lastIndexOf(Object
element to search for
o
)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
public ListIterator<E>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).
public ListIterator<E>
listIterator(int
index of the first element to be returned from the list iterator (by a call to next)
index
)

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
public boolean
needsInserting(Object
The collection element to check
entry
,
int
The index (for indexed collections)
i
,
Type
The type for the element
elemType
)

Implements org.hibernate.collection.spi.PersistentCollection.needsInserting.

Do we need to insert this element?
public boolean
needsUpdating(Object
The collection element to check
entry
,
int
The index (for indexed collections)
i
,
Type
The type for the element
elemType
)

Implements org.hibernate.collection.spi.PersistentCollection.needsUpdating.

Do we need to update this element?
public void
preInsert(CollectionPersister
The collection persister
persister
)

Overrides org.hibernate.collection.internal.AbstractPersistentCollection.preInsert.

Implements org.hibernate.collection.spi.PersistentCollection.preInsert.

Called before inserting rows, to ensure that any surrogate keys are fully generated
public Object
readFrom(ResultSet
The JDBC ResultSet
rs
,
CollectionPersister
The collection role
persister
,
CollectionAliases
The aliases used for the columns making up the collection
descriptor
,
Object
The collection owner
owner
)

Implements org.hibernate.collection.spi.PersistentCollection.readFrom.

Read a row from the JDBC result set
public boolean
remove(Object
element to be removed from this list, if present
o
)

Implements java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).
public Object
remove(int
the index of the element to be removed
index
)

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).
public boolean
removeAll(Collection<E>
collection containing elements to be removed from this list
c
)

Implements java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).
public boolean
retainAll(Collection<E>
collection containing elements to be retained in this list
c
)

Implements java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).
public Object
set(int
index of the element to replace
index
,
Object
element to be stored at the specified position
element
)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public int
size()

Implements java.util.List.size.

Returns the number of elements in this list.
public List<E>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
public Object[]
toArray()

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).
public Object[]
toArray(Object[]
the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
afterInitializebeginReadclearDirtyclearOperationQueuedirtyendReadforceInitializationgetCachedSizegetKeygetOrphansgetOwnergetQueuedOrphansgetRolegetSessiongetSnapshotgetStoredSnapshotgetValuehasQueuedOperationsidentityRemoveidentityRemoveinitializeisClearQueueEnabledisConnectedToSessionisDirectlyAccessibleisDirtyisElementRemovedisInitializedisInverseCollectionisInverseCollectionNoOrphanDeleteisInverseOneToManyOrNoOrphanDeleteisOperationQueueEnabledisPutQueueEnabledisRowUpdatePossibleisUnreferencedneedsRecreateperformQueuedOperationspostActionprepareForPossibleLoadingOutsideTransactionqueuedAdditionIteratorqueueOperationreadreadElementByIndexreadElementExistencereadIndexExistencereadSizereplaceQueuedOperationValuessetCurrentSessionsetDirectlyAccessiblesetInitializedsetOwnersetSnapshotunsetSessionwasInitializedwrite