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

public Class PersistentSet

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

A persistent wrapper for a java.util.Set. The underlying collection is a HashSet.
Author
Gavin King
See Also
java.util.HashSet

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
protected Set<E>
protected transient List<E>
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
elementRemovedUNKNOWN

Constructor Summary

AccessConstructor and Description
public
PersistentSet()

Empty constructor.

public
PersistentSet(SharedSessionContractImplementor
The session to which this set will belong.
session
)

Constructor matching super.

public
PersistentSet(SessionImplementor
The session to which this set will belong.
session
)

Deprecated PersistentSet(SharedSessionContractImplementor) should be used instead.
Instantiates a lazy set (the underlying set is un-initialized).
public
PersistentSet(SharedSessionContractImplementor
The session to which this set will belong.
session
,
Set<E>
The underlying set data.
set
)

Instantiates a non-lazy set (the underlying set is constructed from the incoming set reference).

public
PersistentSet(SessionImplementor
The session to which this set will belong.
session
,
Set<E>
The underlying set data.
set
)

Instantiates a non-lazy set (the underlying set is constructed from the incoming set reference).

Method Summary

Modifier and TypeMethod and Description
public boolean
add(Object
element to be added to this set
value
)

Implements java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation).
public boolean
addAll(Collection<E>
collection containing elements to be added to this set
coll
)

Implements java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
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.
public void
public void
clear()

Implements java.util.Set.clear.

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

Implements java.util.Set.contains.

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

Implements java.util.Set.containsAll.

Returns true if this set 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 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
key
,
int
Unused
i
)

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

Does the given element/entry exist in the collection?
public boolean
equals(Object
object to be compared for equality with this set
other
)

Overrides java.lang.Object.equals.

Implements java.util.Set.equals.

Compares the specified object with this set for equality.
public boolean
equalsSnapshot(CollectionPersister
The collection persister
persister
)

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

Does the current state exactly match the snapshot?
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
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
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Set.hashCode.

Returns the hash code value for this set.
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
isEmpty()

Implements java.util.Set.isEmpty.

Returns true if this set contains no elements.
public boolean
isRowUpdatePossible()

Overrides org.hibernate.collection.internal.AbstractPersistentCollection.isRowUpdatePossible.

Implements org.hibernate.collection.spi.PersistentCollection.isRowUpdatePossible.

Can each element in the collection be mapped unequivocally to a single row in the database?
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.Set.iterator.

Returns an iterator over the elements in this set.
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 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
object to be removed from this set, if present
value
)

Implements java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation).
public boolean
removeAll(Collection<E>
collection containing elements to be removed from this set
coll
)

Implements java.util.Set.removeAll.

Removes from this set 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 set
coll
)

Implements java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation).
public int
size()

Implements java.util.Set.size.

Returns the number of elements in this set (its cardinality).
public Object[]
toArray()

Implements java.util.Set.toArray.

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

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.hibernate.collection.internal.AbstractPersistentCollection:
afterInitializeafterRowInsertclearDirtyclearOperationQueuedirtyforceInitializationgetCachedSizegetIdentifiergetKeygetOrphansgetOwnergetQueuedOrphansgetRolegetSessiongetSnapshotgetStoredSnapshotgetValuehasQueuedOperationsidentityRemoveidentityRemoveinitializeisClearQueueEnabledisConnectedToSessionisDirectlyAccessibleisDirtyisElementRemovedisInitializedisInverseCollectionisInverseCollectionNoOrphanDeleteisInverseOneToManyOrNoOrphanDeleteisOperationQueueEnabledisPutQueueEnabledisUnreferencedneedsRecreateperformQueuedOperationspostActionpreInsertprepareForPossibleLoadingOutsideTransactionqueuedAdditionIteratorqueueOperationreadreadElementByIndexreadElementExistencereadIndexExistencereadSizereplaceQueuedOperationValuessetCurrentSessionsetDirectlyAccessiblesetInitializedsetOwnersetSnapshotunsetSessionwasInitializedwrite