org.hibernate.collection

Class PersistentIdentifierBag

Implemented Interfaces:
List, Serializable, PersistentCollection

public class PersistentIdentifierBag
extends AbstractPersistentCollection
implements List

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

Nested Class Summary

Nested classes/interfaces inherited from class org.hibernate.collection.AbstractPersistentCollection

AbstractPersistentCollection.DelayedOperation

Field Summary

protected Map
identifiers
protected List
values

Fields inherited from class org.hibernate.collection.AbstractPersistentCollection

UNKNOWN

Constructor Summary

PersistentIdentifierBag()
PersistentIdentifierBag(SessionImplementor session)
PersistentIdentifierBag(SessionImplementor session, Collection coll)

Method Summary

boolean
add(Object o)
void
add(int index, Object element)
boolean
addAll(Collection c)
boolean
addAll(int index, Collection c)
void
afterRowInsert(CollectionPersister persister, Object entry, int i)
void
beforeInitialize(CollectionPersister persister, int anticipatedSize)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection c)
Serializable
disassemble(CollectionPersister persister)
boolean
empty()
Iterator
entries(CollectionPersister persister)
boolean
entryExists(Object entry, int i)
boolean
equalsSnapshot(CollectionPersister persister)
Object
get(int index)
Iterator
getDeletes(CollectionPersister persister, boolean indexIsFormula)
Object
getElement(Object entry)
Object
getIdentifier(Object entry, int i)
Object
getIndex(Object entry, int i, CollectionPersister persister)
Collection
getOrphans(Serializable snapshot, String entityName)
Serializable
getSnapshot(CollectionPersister persister)
Object
getSnapshotElement(Object entry, int i)
int
indexOf(Object o)
void
initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
boolean
isEmpty()
boolean
isSnapshotEmpty(Serializable snapshot)
boolean
isWrapper(Object collection)
Iterator
iterator()
int
lastIndexOf(Object o)
ListIterator
listIterator()
ListIterator
listIterator(int index)
boolean
needsInserting(Object entry, int i, Type elemType)
boolean
needsUpdating(Object entry, int i, Type elemType)
void
preInsert(CollectionPersister persister)
Object
readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
boolean
remove(Object o)
Object
remove(int index)
boolean
removeAll(Collection c)
boolean
retainAll(Collection c)
Object
set(int index, Object element)
int
size()
List
subList(int fromIndex, int toIndex)
Object[]
toArray()
Object[]
toArray(Object[] a)

Methods inherited from class org.hibernate.collection.AbstractPersistentCollection

afterInitialize, afterRowInsert, beginRead, clearDirty, dirty, empty, endRead, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, initialize, isClearQueueEnabled, isDirectlyAccessible, isDirty, isOperationQueueEnabled, isPutQueueEnabled, isRowUpdatePossible, isUnreferenced, needsRecreate, performQueuedOperations, postAction, preInsert, queueOperation, queuedAdditionIterator, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, write

Field Details

identifiers

protected Map identifiers

values

protected List values

Constructor Details

PersistentIdentifierBag

public PersistentIdentifierBag()

PersistentIdentifierBag

public PersistentIdentifierBag(SessionImplementor session)

PersistentIdentifierBag

public PersistentIdentifierBag(SessionImplementor session,
                               Collection coll)

Method Details

add

public boolean add(Object o)

add

public void add(int index,
                Object element)

addAll

public boolean addAll(Collection c)

addAll

public boolean addAll(int index,
                      Collection c)

afterRowInsert

public void afterRowInsert(CollectionPersister persister,
                           Object entry,
                           int i)
            throws HibernateException
Specified by:
afterRowInsert in interface PersistentCollection
Overrides:
afterRowInsert in interface AbstractPersistentCollection

beforeInitialize

public void beforeInitialize(CollectionPersister persister,
                             int anticipatedSize)
Specified by:
beforeInitialize in interface PersistentCollection

clear

public void clear()

contains

public boolean contains(Object o)

containsAll

public boolean containsAll(Collection c)

disassemble

public Serializable disassemble(CollectionPersister persister)
            throws HibernateException
Specified by:
disassemble in interface PersistentCollection

empty

public boolean empty()
Specified by:
empty in interface PersistentCollection
Overrides:
empty in interface AbstractPersistentCollection

entries

public Iterator entries(CollectionPersister persister)
Specified by:
entries in interface PersistentCollection

entryExists

public boolean entryExists(Object entry,
                           int i)
Specified by:
entryExists in interface PersistentCollection

equalsSnapshot

public boolean equalsSnapshot(CollectionPersister persister)
            throws HibernateException
Specified by:
equalsSnapshot in interface PersistentCollection

get

public Object get(int index)

getDeletes

public Iterator getDeletes(CollectionPersister persister,
                           boolean indexIsFormula)
            throws HibernateException
Specified by:
getDeletes in interface PersistentCollection

getElement

public Object getElement(Object entry)
Specified by:
getElement in interface PersistentCollection

getIdentifier

public Object getIdentifier(Object entry,
                            int i)
Specified by:
getIdentifier in interface PersistentCollection
Overrides:
getIdentifier in interface AbstractPersistentCollection

getIndex

public Object getIndex(Object entry,
                       int i,
                       CollectionPersister persister)
Specified by:
getIndex in interface PersistentCollection

getOrphans

public Collection getOrphans(Serializable snapshot,
                             String entityName)
            throws HibernateException
Specified by:
getOrphans in interface PersistentCollection
Overrides:
getOrphans in interface AbstractPersistentCollection

getSnapshot

public Serializable getSnapshot(CollectionPersister persister)
            throws HibernateException
Specified by:
getSnapshot in interface PersistentCollection

getSnapshotElement

public Object getSnapshotElement(Object entry,
                                 int i)
Specified by:
getSnapshotElement in interface PersistentCollection

indexOf

public int indexOf(Object o)

initializeFromCache

public void initializeFromCache(CollectionPersister persister,
                                Serializable disassembled,
                                Object owner)
            throws HibernateException
Specified by:
initializeFromCache in interface PersistentCollection

isEmpty

public boolean isEmpty()

isSnapshotEmpty

public boolean isSnapshotEmpty(Serializable snapshot)
Specified by:
isSnapshotEmpty in interface PersistentCollection

isWrapper

public boolean isWrapper(Object collection)
Specified by:
isWrapper in interface PersistentCollection

iterator

public Iterator iterator()

lastIndexOf

public int lastIndexOf(Object o)

listIterator

public ListIterator listIterator()

listIterator

public ListIterator listIterator(int index)

needsInserting

public boolean needsInserting(Object entry,
                              int i,
                              Type elemType)
            throws HibernateException
Specified by:
needsInserting in interface PersistentCollection

needsUpdating

public boolean needsUpdating(Object entry,
                             int i,
                             Type elemType)
            throws HibernateException
Specified by:
needsUpdating in interface PersistentCollection

preInsert

public void preInsert(CollectionPersister persister)
            throws HibernateException
Specified by:
preInsert in interface PersistentCollection
Overrides:
preInsert in interface AbstractPersistentCollection

readFrom

public Object readFrom(ResultSet rs,
                       CollectionPersister persister,
                       CollectionAliases descriptor,
                       Object owner)
            throws HibernateException,
                   SQLException
Specified by:
readFrom in interface PersistentCollection

remove

public boolean remove(Object o)

remove

public Object remove(int index)

removeAll

public boolean removeAll(Collection c)

retainAll

public boolean retainAll(Collection c)

set

public Object set(int index,
                  Object element)

size

public int size()

subList

public List subList(int fromIndex,
                    int toIndex)

toArray

public Object[] toArray()

toArray

public Object[] toArray(Object[] a)