站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

IdentifierBag (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.collection
Class IdentifierBag

java.lang.Object
  extended bynet.sf.hibernate.collection.PersistentCollection
      extended bynet.sf.hibernate.collection.ODMGCollection
          extended bynet.sf.hibernate.collection.IdentifierBag
All Implemented Interfaces:
Collection, org.odmg.DCollection, List, Serializable

public class IdentifierBag
extends ODMGCollection
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
See Also:
Serialized Form

Constructor Summary
IdentifierBag()
           
IdentifierBag(SessionImplementor session)
           
IdentifierBag(SessionImplementor session, Collection coll)
           
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void afterRowInsert(CollectionPersister persister, Object entry, int i)
          Called after inserting a row, to fetch the natively generated id
 void beforeInitialize(CollectionPersister persister)
          Called before any elements are read into the collection, allowing appropriate initializations to occur.
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
protected  JDBCException convert(SQLException sqlException, String message)
           
 Serializable disassemble(CollectionPersister persister)
          Disassemble the collection, ready for the cache
 boolean empty()
          Is the initialized collection empty?
 Iterator entries()
          Iterate all collection entries, during update of the database
 boolean entryExists(Object entry, int i)
          Does an element exist at this entry in the collection?
 boolean equalsSnapshot(Type elementType)
          Does the current state exactly match the snapshot?
 Object get(int index)
           
 Iterator getDeletes(Type elemType)
          Get all the elements that need deleting
 Object getIndex(Object entry, int i)
          Get the index of the given collection entry
 Collection getOrphans(Serializable snapshot)
          get all "orphaned" elements
 int indexOf(Object o)
           
 void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
          Read the state of the collection from a disassembled cached value
 boolean isEmpty()
           
 boolean isWrapper(Object collection)
          Is this the wrapper for the given underlying collection instance?
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 boolean needsInserting(Object entry, int i, Type elemType)
          Do we need to insert this element?
 boolean needsUpdating(Object entry, int i, Type elemType)
          Do we need to update this element?
 void preInsert(CollectionPersister persister)
          Called before inserting rows, to ensure that any surrogate keys are fully generated
 Object readFrom(ResultSet rs, CollectionPersister persister, Object owner)
          Read a row from the JDBC result set
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 int size()
           
protected  Serializable snapshot(CollectionPersister persister)
          Return a new snapshot of the current state
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 void writeTo(PreparedStatement st, CollectionPersister persister, Object entry, int i, boolean writeOrder)
          Write a row to the JDBC prepared statement
 
Methods inherited from class net.sf.hibernate.collection.ODMGCollection
existsElement, query, select, selectElement
 
Methods inherited from class net.sf.hibernate.collection.PersistentCollection
beginRead, delayedAddAll, endRead, forceInitialization, getCollectionSnapshot, getOrphans, getSession, getSnapshot, getSnapshot, getValue, hasQueuedAdditions, initialize, isDirectlyAccessible, needsRecreate, postFlush, queueAdd, queueAddAll, queuedAdditionIterator, read, setCollectionSnapshot, setCurrentSession, setDirectlyAccessible, setInitialized, unsetSession, wasInitialized, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

IdentifierBag

public IdentifierBag(SessionImplementor session)

IdentifierBag

public IdentifierBag()

IdentifierBag

public IdentifierBag(SessionImplementor session,
                     Collection coll)
Method Detail

initializeFromCache

public void initializeFromCache(CollectionPersister persister,
                                Serializable disassembled,
                                Object owner)
                         throws HibernateException
Description copied from class: PersistentCollection
Read the state of the collection from a disassembled cached value

Specified by:
initializeFromCache in class PersistentCollection
Throws:
HibernateException

isWrapper

public boolean isWrapper(Object collection)
Description copied from class: PersistentCollection
Is this the wrapper for the given underlying collection instance?

Specified by:
isWrapper in class PersistentCollection

add

public boolean add(Object o)
Specified by:
add in interface List

clear

public void clear()
Specified by:
clear in interface List

contains

public boolean contains(Object o)
Specified by:
contains in interface List

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface List

iterator

public Iterator iterator()
Specified by:
iterator in interface List

remove

public boolean remove(Object o)
Specified by:
remove in interface List

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface List

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface List

size

public int size()
Specified by:
size in interface List

toArray

public Object[] toArray()
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface List

beforeInitialize

public void beforeInitialize(CollectionPersister persister)
Description copied from class: PersistentCollection
Called before any elements are read into the collection, allowing appropriate initializations to occur.

Specified by:
beforeInitialize in class PersistentCollection

disassemble

public Serializable disassemble(CollectionPersister persister)
                         throws HibernateException
Description copied from class: PersistentCollection
Disassemble the collection, ready for the cache

Specified by:
disassemble in class PersistentCollection
Throws:
HibernateException

empty

public boolean empty()
Description copied from class: PersistentCollection
Is the initialized collection empty?

Specified by:
empty in class PersistentCollection

entries

public Iterator entries()
Description copied from class: PersistentCollection
Iterate all collection entries, during update of the database

Specified by:
entries in class PersistentCollection

entryExists

public boolean entryExists(Object entry,
                           int i)
Description copied from class: PersistentCollection
Does an element exist at this entry in the collection?

Specified by:
entryExists in class PersistentCollection

equalsSnapshot

public boolean equalsSnapshot(Type elementType)
                       throws HibernateException
Description copied from class: PersistentCollection
Does the current state exactly match the snapshot?

Specified by:
equalsSnapshot in class PersistentCollection
Throws:
HibernateException

getDeletes

public Iterator getDeletes(Type elemType)
                    throws HibernateException
Description copied from class: PersistentCollection
Get all the elements that need deleting

Specified by:
getDeletes in class PersistentCollection
Throws:
HibernateException

getIndex

public Object getIndex(Object entry,
                       int i)
Description copied from class: PersistentCollection
Get the index of the given collection entry

Specified by:
getIndex in class PersistentCollection

needsInserting

public boolean needsInserting(Object entry,
                              int i,
                              Type elemType)
                       throws HibernateException
Description copied from class: PersistentCollection
Do we need to insert this element?

Specified by:
needsInserting in class PersistentCollection
Throws:
HibernateException

needsUpdating

public boolean needsUpdating(Object entry,
                             int i,
                             Type elemType)
                      throws HibernateException
Description copied from class: PersistentCollection
Do we need to update this element?

Specified by:
needsUpdating in class PersistentCollection
Throws:
HibernateException

readFrom

public Object readFrom(ResultSet rs,
                       CollectionPersister persister,
                       Object owner)
                throws HibernateException,
                       SQLException
Description copied from class: PersistentCollection
Read a row from the JDBC result set

Specified by:
readFrom in class PersistentCollection
Throws:
HibernateException
SQLException

snapshot

protected Serializable snapshot(CollectionPersister persister)
                         throws HibernateException
Description copied from class: PersistentCollection
Return a new snapshot of the current state

Specified by:
snapshot in class PersistentCollection
Throws:
HibernateException

getOrphans

public Collection getOrphans(Serializable snapshot)
                      throws HibernateException
Description copied from class: PersistentCollection
get all "orphaned" elements

Specified by:
getOrphans in class PersistentCollection
Throws:
HibernateException

preInsert

public void preInsert(CollectionPersister persister)
               throws HibernateException
Description copied from class: PersistentCollection
Called before inserting rows, to ensure that any surrogate keys are fully generated

Overrides:
preInsert in class PersistentCollection
Throws:
HibernateException

writeTo

public void writeTo(PreparedStatement st,
                    CollectionPersister persister,
                    Object entry,
                    int i,
                    boolean writeOrder)
             throws HibernateException,
                    SQLException
Description copied from class: PersistentCollection
Write a row to the JDBC prepared statement

Specified by:
writeTo in class PersistentCollection
Throws:
HibernateException
SQLException

add

public void add(int index,
                Object element)
Specified by:
add in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

get

public Object get(int index)
Specified by:
get in interface List

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface List

afterRowInsert

public void afterRowInsert(CollectionPersister persister,
                           Object entry,
                           int i)
                    throws HibernateException
Description copied from class: PersistentCollection
Called after inserting a row, to fetch the natively generated id

Overrides:
afterRowInsert in class PersistentCollection
Throws:
HibernateException

convert

protected JDBCException convert(SQLException sqlException,
                                String message)