Top Description Inners Fields Constructors Methods
org.hibernate.collection

public Class PersistentBag

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, .Iterator, .List, .ListIterator, org.hibernate.EntityMode, .HibernateException, org.hibernate.engine.SessionImplementor, org.hibernate.loader.CollectionAliases, org.hibernate.persister.collection.CollectionPersister, org.hibernate.type.Type

An unordered, unkeyed collection that can contain the same element multiple times. The Java collections API, curiously, has no Bag. Most developers seem to use Lists to represent bag semantics, so Hibernate follows this practice.
Author
Gavin King

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
protected List<E>
Inherited from org.hibernate.collection.AbstractPersistentCollection:
UNKNOWN

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

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

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
i
,
Object
element to be inserted
o
)

Implements java.util.List.add.

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

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 boolean
addAll(int
index at which to insert the first element from the specified collection
i
,
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 void
beforeInitialize(CollectionPersister
The underlying collection persister.
persister
,
int
The anticipated size of the collection after initilization is complete.
anticipatedSize
)

Implements org.hibernate.collection.PersistentCollection.beforeInitialize.

Called before any elements are read into the collection, allowing appropriate initializations to occur.
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
object
)

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.
private int
countOccurrences(Object element, List<E> list, Type elementType, EntityMode entityMode)

public Serializable
disassemble(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.disassemble.

Disassemble the collection, ready for the cache
public boolean
public Iterator<E>
entries(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.entries.

Iterate all collection entries, during update of the database
public boolean
entryExists(Object entry, int i)

Implements org.hibernate.collection.PersistentCollection.entryExists.

Does an element exist at this entry in the collection?
public boolean
equals(Object
the object to be compared for equality with this list
obj
)

Overrides java.lang.Object.equals.

Implements java.util.List.equals.

Bag does not respect the collection API and do an JVM instance comparison to do the equals.
public boolean
equalsSnapshot(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.equalsSnapshot.

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

Implements java.util.List.get.

Returns the element at the specified position in this list.
public Iterator<E>
getDeletes(CollectionPersister persister, boolean indexIsFormula)

Implements org.hibernate.collection.PersistentCollection.getDeletes.

Get all the elements that need deleting
public Object
getElement(Object entry)

Implements org.hibernate.collection.PersistentCollection.getElement.

Get the value of the given collection entry
public Object
getIndex(Object entry, int i, CollectionPersister
it was more elegant before we added this...
persister
)

Implements org.hibernate.collection.PersistentCollection.getIndex.

Get the index of the given collection entry
public Collection<E>
public Serializable
getSnapshot(CollectionPersister persister)

Implements org.hibernate.collection.PersistentCollection.getSnapshot.

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

Implements org.hibernate.collection.PersistentCollection.getSnapshotElement.

Get the snapshot value of the given collection entry
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.List.hashCode.

Returns the hash code value for this list.
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 persister, Serializable disassembled, Object owner)

Implements org.hibernate.collection.PersistentCollection.initializeFromCache.

Read the state of the collection from a disassembled cached value
public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.
public boolean
public boolean
public boolean
isWrapper(Object collection)

Implements org.hibernate.collection.PersistentCollection.isWrapper.

Is this the wrapper for the given underlying 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)
i
)

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 entry, int i, Type elemType)

Implements org.hibernate.collection.PersistentCollection.needsInserting.

Do we need to insert this element?
public boolean
public boolean
needsUpdating(Object entry, int i, Type elemType)

Implements org.hibernate.collection.PersistentCollection.needsUpdating.

Do we need to update this element?
public int
public Object
readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)

Implements org.hibernate.collection.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
i
)

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
i
,
Object
element to be stored at the specified position
o
)

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
start
,
int
high endpoint (exclusive) of the subList
end
)

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.
public String
toString()

Overrides java.lang.Object.toString.

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