org.hibernate.collection
Class PersistentSet

java.lang.Object
  extended by org.hibernate.collection.AbstractPersistentCollection
      extended by org.hibernate.collection.PersistentSet
All Implemented Interfaces:
Serializable, Iterable, Collection, Set, PersistentCollection
Direct Known Subclasses:
PersistentSortedSet

public class PersistentSet
extends AbstractPersistentCollection
implements Set

A persistent wrapper for a java.util.Set. The underlying collection is a HashSet.

Author:
Gavin King
See Also:
HashSet, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.collection.AbstractPersistentCollection
AbstractPersistentCollection.DelayedOperation
 
Field Summary
protected  Set set
           
protected  List tempList
           
 
Fields inherited from class org.hibernate.collection.AbstractPersistentCollection
UNKNOWN
 
Constructor Summary
PersistentSet()
          Empty constructor.
PersistentSet(SessionImplementor session)
          Constructor matching super.
PersistentSet(SessionImplementor session, Set set)
          Instantiates a non-lazy set (the underlying set is constructed from the incoming set reference).
 
Method Summary
 boolean add(Object value)
           
 boolean addAll(Collection coll)
           
 void beforeInitialize(CollectionPersister persister, int anticipatedSize)
          Called before any elements are read into the collection, allowing appropriate initializations to occur.
 void beginRead()
          Called just before reading any rows from the JDBC result set
 void clear()
           
 boolean contains(Object object)
           
 boolean containsAll(Collection coll)
           
 Serializable disassemble(CollectionPersister persister)
          Disassemble the collection, ready for the cache
 boolean empty()
          Is the initialized collection empty?
 boolean endRead()
          Called after reading all rows from the JDBC result set
 Iterator entries(CollectionPersister persister)
          Iterate all collection entries, during update of the database
 boolean entryExists(Object key, int i)
          Does an element exist at this entry in the collection?
 boolean equals(Object other)
           
 boolean equalsSnapshot(CollectionPersister persister)
          Does the current state exactly match the snapshot?
 Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
          Get all the elements that need deleting
 Object getElement(Object entry)
          Get the value of the given collection entry
 Object getIndex(Object entry, int i, CollectionPersister persister)
          Get the index of the given collection entry
 Collection getOrphans(Serializable snapshot, String entityName)
          get all "orphaned" elements
 Serializable getSnapshot(CollectionPersister persister)
          Return a new snapshot of the current state of the collection
 Object getSnapshotElement(Object entry, int i)
          Get the snapshot value of the given collection entry
 int hashCode()
           
 void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
          Read the state of the collection from a disassembled cached value
 boolean isEmpty()
           
 boolean isRowUpdatePossible()
           
 boolean isSnapshotEmpty(Serializable snapshot)
          Is the snapshot empty?
 boolean isWrapper(Object collection)
          Is this the wrapper for the given underlying collection instance?
 Iterator iterator()
           
 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?
 Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
          Read a row from the JDBC result set
 boolean remove(Object value)
           
 boolean removeAll(Collection coll)
           
 boolean retainAll(Collection coll)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] array)
           
 String toString()
           
 
Methods inherited from class org.hibernate.collection.AbstractPersistentCollection
afterInitialize, afterRowInsert, clearDirty, dirty, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, initialize, isClearQueueEnabled, isDirectlyAccessible, isDirty, isOperationQueueEnabled, isPutQueueEnabled, isUnreferenced, needsRecreate, performQueuedOperations, postAction, preInsert, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

set

protected Set set

tempList

protected transient List tempList
Constructor Detail

PersistentSet

public PersistentSet()
Empty constructor.

Note: this form is not ever ever ever used by Hibernate; it is, however, needed for SOAP libraries and other such marshalling code.


PersistentSet

public PersistentSet(SessionImplementor session)
Constructor matching super. Instantiates a lazy set (the underlying set is un-initialized).

Parameters:
session - The session to which this set will belong.

PersistentSet

public PersistentSet(SessionImplementor session,
                     Set set)
Instantiates a non-lazy set (the underlying set is constructed from the incoming set reference).

Parameters:
session - The session to which this set will belong.
set - The underlying set data.
Method Detail

getSnapshot

public Serializable getSnapshot(CollectionPersister persister)
                         throws HibernateException
Description copied from interface: PersistentCollection
Return a new snapshot of the current state of the collection

Specified by:
getSnapshot in interface PersistentCollection
Throws:
HibernateException

getOrphans

public Collection getOrphans(Serializable snapshot,
                             String entityName)
                      throws HibernateException
Description copied from class: AbstractPersistentCollection
get all "orphaned" elements

Specified by:
getOrphans in interface PersistentCollection
Specified by:
getOrphans in class AbstractPersistentCollection
Throws:
HibernateException

equalsSnapshot

public boolean equalsSnapshot(CollectionPersister persister)
                       throws HibernateException
Description copied from interface: PersistentCollection
Does the current state exactly match the snapshot?

Specified by:
equalsSnapshot in interface PersistentCollection
Throws:
HibernateException

isSnapshotEmpty

public boolean isSnapshotEmpty(Serializable snapshot)
Description copied from interface: PersistentCollection
Is the snapshot empty?

Specified by:
isSnapshotEmpty in interface PersistentCollection

beforeInitialize

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

Specified by:
beforeInitialize in interface PersistentCollection
Parameters:
persister - The underlying collection persister.
anticipatedSize - The anticipated size of the collection after initilization is complete.

initializeFromCache

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

Specified by:
initializeFromCache in interface PersistentCollection
Throws:
HibernateException

empty

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

Specified by:
empty in interface PersistentCollection
Specified by:
empty in class AbstractPersistentCollection

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface Set
See Also:
Set.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set
See Also:
Set.isEmpty()

contains

public boolean contains(Object object)
Specified by:
contains in interface Collection
Specified by:
contains in interface Set
See Also:
Set.contains(Object)

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set
See Also:
Set.iterator()

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
See Also:
Set.toArray()

toArray

public Object[] toArray(Object[] array)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set
See Also:
Set.toArray(Object[])

add

public boolean add(Object value)
Specified by:
add in interface Collection
Specified by:
add in interface Set
See Also:
Set.add(Object)

remove

public boolean remove(Object value)
Specified by:
remove in interface Collection
Specified by:
remove in interface Set
See Also:
Set.remove(Object)

containsAll

public boolean containsAll(Collection coll)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface Set
See Also:
Set.containsAll(Collection)

addAll

public boolean addAll(Collection coll)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface Set
See Also:
Set.addAll(Collection)

retainAll

public boolean retainAll(Collection coll)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface Set
See Also:
Set.retainAll(Collection)

removeAll

public boolean removeAll(Collection coll)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface Set
See Also:
Set.removeAll(Collection)

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface Set
See Also:
Set.clear()

toString

public String toString()
Overrides:
toString in class Object

readFrom

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

Specified by:
readFrom in interface PersistentCollection
Throws:
HibernateException
SQLException

beginRead

public void beginRead()
Description copied from class: AbstractPersistentCollection
Called just before reading any rows from the JDBC result set

Specified by:
beginRead in interface PersistentCollection
Overrides:
beginRead in class AbstractPersistentCollection

endRead

public boolean endRead()
Description copied from class: AbstractPersistentCollection
Called after reading all rows from the JDBC result set

Specified by:
endRead in interface PersistentCollection
Overrides:
endRead in class AbstractPersistentCollection

entries

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

Specified by:
entries in interface PersistentCollection

disassemble

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

Specified by:
disassemble in interface PersistentCollection
Throws:
HibernateException

getDeletes

public Iterator getDeletes(CollectionPersister persister,
                           boolean indexIsFormula)
                    throws HibernateException
Description copied from interface: PersistentCollection
Get all the elements that need deleting

Specified by:
getDeletes in interface PersistentCollection
Throws:
HibernateException

needsInserting

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

Specified by:
needsInserting in interface PersistentCollection
Throws:
HibernateException

needsUpdating

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

Specified by:
needsUpdating in interface PersistentCollection

isRowUpdatePossible

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

getIndex

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

Specified by:
getIndex in interface PersistentCollection
persister - it was more elegant before we added this...

getElement

public Object getElement(Object entry)
Description copied from interface: PersistentCollection
Get the value of the given collection entry

Specified by:
getElement in interface PersistentCollection

getSnapshotElement

public Object getSnapshotElement(Object entry,
                                 int i)
Description copied from interface: PersistentCollection
Get the snapshot value of the given collection entry

Specified by:
getSnapshotElement in interface PersistentCollection

equals

public boolean equals(Object other)
Specified by:
equals in interface Collection
Specified by:
equals in interface Set
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface Set
Overrides:
hashCode in class Object

entryExists

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

Specified by:
entryExists in interface PersistentCollection

isWrapper

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

Specified by:
isWrapper in interface PersistentCollection


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.