|
|||||||||
| Home >> All >> org >> hibernate >> [ collection overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.hibernate.collection
Class PersistentBag

java.lang.Objectorg.hibernate.collection.AbstractPersistentCollection
org.hibernate.collection.PersistentBag
- All Implemented Interfaces:
- java.util.Collection, java.lang.Iterable, java.util.List, PersistentCollection, java.io.Serializable
- public class PersistentBag
- extends AbstractPersistentCollection
- implements java.util.List
- extends AbstractPersistentCollection
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.
| Nested Class Summary | |
(package private) class |
PersistentBag.Clear
|
(package private) class |
PersistentBag.SimpleAdd
|
| Nested classes inherited from class org.hibernate.collection.AbstractPersistentCollection |
AbstractPersistentCollection.DelayedOperation, AbstractPersistentCollection.IteratorProxy, AbstractPersistentCollection.ListIteratorProxy, AbstractPersistentCollection.ListProxy, AbstractPersistentCollection.SetProxy |
| Field Summary | |
protected java.util.List |
bag
|
| Fields inherited from class org.hibernate.collection.AbstractPersistentCollection |
UNKNOWN |
| Constructor Summary | |
PersistentBag()
|
|
PersistentBag(org.hibernate.engine.SessionImplementor session)
|
|
PersistentBag(org.hibernate.engine.SessionImplementor session,
java.util.Collection coll)
|
|
| Method Summary | |
void |
add(int i,
java.lang.Object o)
Insert an element into the list at a given position (optional operation). |
boolean |
add(java.lang.Object object)
Add an element to the end of the list (optional operation). |
boolean |
addAll(java.util.Collection values)
Add the contents of a collection to the end of the list (optional operation). |
boolean |
addAll(int i,
java.util.Collection c)
Insert the contents of a collection into the list at a given position (optional operation). |
void |
beforeInitialize(org.hibernate.persister.collection.CollectionPersister persister)
Called before any elements are read into the collection, allowing appropriate initializations to occur. |
void |
clear()
Clear the list, such that a subsequent call to isEmpty() would return true (optional operation). |
boolean |
contains(java.lang.Object object)
Test whether this list contains a given object as one of its elements. |
boolean |
containsAll(java.util.Collection c)
Test whether this list contains every element in a given collection. |
private int |
countOccurrences(java.lang.Object element,
java.util.List list,
org.hibernate.type.Type elementType,
org.hibernate.EntityMode entityMode)
|
java.io.Serializable |
disassemble(org.hibernate.persister.collection.CollectionPersister persister)
Disassemble the collection, ready for the cache |
boolean |
empty()
Is the initialized collection empty? |
java.util.Iterator |
entries(org.hibernate.persister.collection.CollectionPersister persister)
Iterate all collection entries, during update of the database |
boolean |
entryExists(java.lang.Object entry,
int i)
Does an element exist at this entry in the collection? |
boolean |
equals(java.lang.Object obj)
Bag does not respect the collection API and do an JVM instance comparison to do the equals. |
boolean |
equalsSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
Does the current state exactly match the snapshot? |
java.lang.Object |
get(int i)
Get the element at a given index in this list. |
java.util.Iterator |
getDeletes(org.hibernate.persister.collection.CollectionPersister persister,
boolean indexIsFormula)
Get all the elements that need deleting |
java.lang.Object |
getElement(java.lang.Object entry)
Get the value of the given collection entry |
java.lang.Object |
getIndex(java.lang.Object entry,
int i,
org.hibernate.persister.collection.CollectionPersister persister)
Get the index of the given collection entry |
java.util.Collection |
getOrphans(java.io.Serializable snapshot,
java.lang.String entityName)
get all "orphaned" elements |
java.io.Serializable |
getSnapshot(org.hibernate.persister.collection.CollectionPersister persister)
Return a new snapshot of the current state of the collection |
java.lang.Object |
getSnapshotElement(java.lang.Object entry,
int i)
Get the snapshot value of the given collection entry |
int |
hashCode()
Obtains a hash code for this list. |
int |
indexOf(java.lang.Object o)
Obtain the first index at which a given object is to be found in this list. |
void |
initializeFromCache(org.hibernate.persister.collection.CollectionPersister persister,
java.io.Serializable disassembled,
java.lang.Object owner)
Read the state of the collection from a disassembled cached value |
boolean |
isEmpty()
Test whether this list is empty, that is, if size() == 0. |
boolean |
isRowUpdatePossible()
|
boolean |
isSnapshotEmpty(java.io.Serializable snapshot)
Is the snapshot empty? |
boolean |
isWrapper(java.lang.Object collection)
Is this the wrapper for the given underlying collection instance? |
java.util.Iterator |
iterator()
Obtain an Iterator over this list, whose sequence is the list order. |
int |
lastIndexOf(java.lang.Object o)
Obtain the last index at which a given object is to be found in this list. |
java.util.ListIterator |
listIterator()
Obtain a ListIterator over this list, starting at the beginning. |
java.util.ListIterator |
listIterator(int i)
Obtain a ListIterator over this list, starting at a given position. |
boolean |
needsInserting(java.lang.Object entry,
int i,
org.hibernate.type.Type elemType)
Do we need to insert this element? |
boolean |
needsRecreate(org.hibernate.persister.collection.CollectionPersister persister)
Do we need to completely recreate this collection when it changes? |
boolean |
needsUpdating(java.lang.Object entry,
int i,
org.hibernate.type.Type elemType)
Do we need to update this element? |
int |
occurrences(java.lang.Object o)
|
java.lang.Object |
readFrom(java.sql.ResultSet rs,
org.hibernate.persister.collection.CollectionPersister persister,
org.hibernate.loader.CollectionAliases descriptor,
java.lang.Object owner)
Read a row from the JDBC result set |
java.lang.Object |
remove(int i)
Remove the element at a given position in this list (optional operation). |
boolean |
remove(java.lang.Object o)
Remove the first occurence of an object from this list (optional operation). |
boolean |
removeAll(java.util.Collection c)
Remove all elements of a given collection from this list (optional operation). |
boolean |
retainAll(java.util.Collection c)
Remove all elements of this list that are not contained in a given collection (optional operation). |
java.lang.Object |
set(int i,
java.lang.Object o)
Replace an element of this list with another object (optional operation). |
int |
size()
Get the number of elements in this list. |
java.util.List |
subList(int start,
int end)
Obtain a List view of a subsection of this list, from fromIndex (inclusive) to toIndex (exclusive). |
java.lang.Object[] |
toArray()
Copy the current contents of this list into an array. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Copy the current contents of this list into an array. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
bag
protected java.util.List bag
| Constructor Detail |
PersistentBag
public PersistentBag(org.hibernate.engine.SessionImplementor session)
PersistentBag
public PersistentBag(org.hibernate.engine.SessionImplementor session, java.util.Collection coll)
PersistentBag
public PersistentBag()
| Method Detail |
isWrapper
public boolean isWrapper(java.lang.Object collection)
- Description copied from interface:
PersistentCollection - Is this the wrapper for the given underlying collection instance?
- Specified by:
isWrapperin interfacePersistentCollection
empty
public boolean empty()
- Description copied from class:
AbstractPersistentCollection - Is the initialized collection empty?
- Specified by:
emptyin interfacePersistentCollection- Specified by:
emptyin classAbstractPersistentCollection
entries
public java.util.Iterator entries(org.hibernate.persister.collection.CollectionPersister persister)
- Description copied from interface:
PersistentCollection - Iterate all collection entries, during update of the database
- Specified by:
entriesin interfacePersistentCollection
readFrom
public java.lang.Object readFrom(java.sql.ResultSet rs, org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.loader.CollectionAliases descriptor, java.lang.Object owner) throws org.hibernate.HibernateException, java.sql.SQLException
- Description copied from interface:
PersistentCollection - Read a row from the JDBC result set
- Specified by:
readFromin interfacePersistentCollection
beforeInitialize
public void beforeInitialize(org.hibernate.persister.collection.CollectionPersister persister)
- Description copied from interface:
PersistentCollection - Called before any elements are read into the collection,
allowing appropriate initializations to occur.
- Specified by:
beforeInitializein interfacePersistentCollection
equalsSnapshot
public boolean equalsSnapshot(org.hibernate.persister.collection.CollectionPersister persister) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Does the current state exactly match the snapshot?
- Specified by:
equalsSnapshotin interfacePersistentCollection
isSnapshotEmpty
public boolean isSnapshotEmpty(java.io.Serializable snapshot)
- Description copied from interface:
PersistentCollection - Is the snapshot empty?
- Specified by:
isSnapshotEmptyin interfacePersistentCollection
countOccurrences
private int countOccurrences(java.lang.Object element, java.util.List list, org.hibernate.type.Type elementType, org.hibernate.EntityMode entityMode) throws org.hibernate.HibernateException
getSnapshot
public java.io.Serializable getSnapshot(org.hibernate.persister.collection.CollectionPersister persister) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Return a new snapshot of the current state of the collection
- Specified by:
getSnapshotin interfacePersistentCollection
getOrphans
public java.util.Collection getOrphans(java.io.Serializable snapshot, java.lang.String entityName) throws org.hibernate.HibernateException
- Description copied from class:
AbstractPersistentCollection - get all "orphaned" elements
- Specified by:
getOrphansin interfacePersistentCollection- Specified by:
getOrphansin classAbstractPersistentCollection
disassemble
public java.io.Serializable disassemble(org.hibernate.persister.collection.CollectionPersister persister) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Disassemble the collection, ready for the cache
- Specified by:
disassemblein interfacePersistentCollection
initializeFromCache
public void initializeFromCache(org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable disassembled, java.lang.Object owner) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Read the state of the collection from a disassembled cached value
- Specified by:
initializeFromCachein interfacePersistentCollection
needsRecreate
public boolean needsRecreate(org.hibernate.persister.collection.CollectionPersister persister)
- Description copied from class:
AbstractPersistentCollection - Do we need to completely recreate this collection when it changes?
- Specified by:
needsRecreatein interfacePersistentCollection- Overrides:
needsRecreatein classAbstractPersistentCollection
getDeletes
public java.util.Iterator getDeletes(org.hibernate.persister.collection.CollectionPersister persister, boolean indexIsFormula) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Get all the elements that need deleting
- Specified by:
getDeletesin interfacePersistentCollection
needsInserting
public boolean needsInserting(java.lang.Object entry, int i, org.hibernate.type.Type elemType) throws org.hibernate.HibernateException
- Description copied from interface:
PersistentCollection - Do we need to insert this element?
- Specified by:
needsInsertingin interfacePersistentCollection
isRowUpdatePossible
public boolean isRowUpdatePossible()
- Specified by:
isRowUpdatePossiblein interfacePersistentCollection- Overrides:
isRowUpdatePossiblein classAbstractPersistentCollection
needsUpdating
public boolean needsUpdating(java.lang.Object entry, int i, org.hibernate.type.Type elemType)
- Description copied from interface:
PersistentCollection - Do we need to update this element?
- Specified by:
needsUpdatingin interfacePersistentCollection
size
public int size()
- Description copied from interface:
java.util.List - Get the number of elements in this list. If the list contains more
than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.
- Specified by:
sizein interfacejava.util.List
isEmpty
public boolean isEmpty()
- Description copied from interface:
java.util.List - Test whether this list is empty, that is, if size() == 0.
- Specified by:
isEmptyin interfacejava.util.List
contains
public boolean contains(java.lang.Object object)
- Description copied from interface:
java.util.List - Test whether this list contains a given object as one of its elements.
This is defined as the existence of an element e such that
o == null ? e == null : o.equals(e).- Specified by:
containsin interfacejava.util.List
iterator
public java.util.Iterator iterator()
- Description copied from interface:
java.util.List - Obtain an Iterator over this list, whose sequence is the list order.
- Specified by:
iteratorin interfacejava.util.List
toArray
public java.lang.Object[] toArray()
- Description copied from interface:
java.util.List - Copy the current contents of this list into an array.
- Specified by:
toArrayin interfacejava.util.List
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
- Description copied from interface:
java.util.List - Copy the current contents of this list into an array. If the array passed
as an argument has length less than that of this list, an array of the
same run-time type as a, and length equal to the length of this list, is
allocated using Reflection. Otherwise, a itself is used. The elements of
this list are copied into it, and if there is space in the array, the
following element is set to null. The resultant array is returned.
Note: The fact that the following element is set to null is only useful
if it is known that this list does not contain any null elements.
- Specified by:
toArrayin interfacejava.util.List
add
public boolean add(java.lang.Object object)
- Description copied from interface:
java.util.List - Add an element to the end of the list (optional operation). If the list
imposes restraints on what can be inserted, such as no null elements,
this should be documented.
- Specified by:
addin interfacejava.util.List
remove
public boolean remove(java.lang.Object o)
- Description copied from interface:
java.util.List - Remove the first occurence of an object from this list (optional
operation). That is, remove the first element e such that
o == null ? e == null : o.equals(e).- Specified by:
removein interfacejava.util.List
containsAll
public boolean containsAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Test whether this list contains every element in a given collection.
- Specified by:
containsAllin interfacejava.util.List
addAll
public boolean addAll(java.util.Collection values)
- Description copied from interface:
java.util.List - Add the contents of a collection to the end of the list (optional
operation). This operation is undefined if this list is modified
during the operation (for example, if you try to insert a list into
itself).
- Specified by:
addAllin interfacejava.util.List
removeAll
public boolean removeAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Remove all elements of a given collection from this list (optional
operation). That is, remove every element e such that c.contains(e).
- Specified by:
removeAllin interfacejava.util.List
retainAll
public boolean retainAll(java.util.Collection c)
- Description copied from interface:
java.util.List - Remove all elements of this list that are not contained in a given
collection (optional operation). That is, remove every element e such
that !c.contains(e).
- Specified by:
retainAllin interfacejava.util.List
clear
public void clear()
- Description copied from interface:
java.util.List - Clear the list, such that a subsequent call to isEmpty() would return
true (optional operation).
- Specified by:
clearin interfacejava.util.List
getIndex
public java.lang.Object getIndex(java.lang.Object entry, int i, org.hibernate.persister.collection.CollectionPersister persister)
- Description copied from interface:
PersistentCollection - Get the index of the given collection entry
- Specified by:
getIndexin interfacePersistentCollection
getElement
public java.lang.Object getElement(java.lang.Object entry)
- Description copied from interface:
PersistentCollection - Get the value of the given collection entry
- Specified by:
getElementin interfacePersistentCollection
getSnapshotElement
public java.lang.Object getSnapshotElement(java.lang.Object entry, int i)
- Description copied from interface:
PersistentCollection - Get the snapshot value of the given collection entry
- Specified by:
getSnapshotElementin interfacePersistentCollection
occurrences
public int occurrences(java.lang.Object o)
add
public void add(int i,
java.lang.Object o)
- Description copied from interface:
java.util.List - Insert an element into the list at a given position (optional operation).
This shifts all existing elements from that position to the end one
index to the right. This version of add has no return, since it is
assumed to always succeed if there is no exception.
- Specified by:
addin interfacejava.util.List
addAll
public boolean addAll(int i,
java.util.Collection c)
- Description copied from interface:
java.util.List - Insert the contents of a collection into the list at a given position
(optional operation). Shift all elements at that position to the right
by the number of elements inserted. This operation is undefined if
this list is modified during the operation (for example, if you try
to insert a list into itself).
- Specified by:
addAllin interfacejava.util.List
get
public java.lang.Object get(int i)
- Description copied from interface:
java.util.List - Get the element at a given index in this list.
- Specified by:
getin interfacejava.util.List
indexOf
public int indexOf(java.lang.Object o)
- Description copied from interface:
java.util.List - Obtain the first index at which a given object is to be found in this
list.
- Specified by:
indexOfin interfacejava.util.List
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Description copied from interface:
java.util.List - Obtain the last index at which a given object is to be found in this
list.
- Specified by:
lastIndexOfin interfacejava.util.List
listIterator
public java.util.ListIterator listIterator()
- Description copied from interface:
java.util.List - Obtain a ListIterator over this list, starting at the beginning.
- Specified by:
listIteratorin interfacejava.util.List
listIterator
public java.util.ListIterator listIterator(int i)
- Description copied from interface:
java.util.List - Obtain a ListIterator over this list, starting at a given position.
A first call to next() would return the same as get(index), and a
first call to previous() would return the same as get(index - 1).
- Specified by:
listIteratorin interfacejava.util.List
remove
public java.lang.Object remove(int i)
- Description copied from interface:
java.util.List - Remove the element at a given position in this list (optional operation).
Shifts all remaining elements to the left to fill the gap.
- Specified by:
removein interfacejava.util.List
set
public java.lang.Object set(int i, java.lang.Object o)
- Description copied from interface:
java.util.List - Replace an element of this list with another object (optional operation).
- Specified by:
setin interfacejava.util.List
subList
public java.util.List subList(int start, int end)
- Description copied from interface:
java.util.List - Obtain a List view of a subsection of this list, from fromIndex
(inclusive) to toIndex (exclusive). If the two indices are equal, the
sublist is empty. The returned list should be modifiable if and only
if this list is modifiable. Changes to the returned list should be
reflected in this list. If this list is structurally modified in
any way other than through the returned list, the result of any subsequent
operations on the returned list is undefined.
- Specified by:
subListin interfacejava.util.List
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
entryExists
public boolean entryExists(java.lang.Object entry, int i)
- Description copied from interface:
PersistentCollection - Does an element exist at this entry in the collection?
- Specified by:
entryExistsin interfacePersistentCollection
equals
public boolean equals(java.lang.Object obj)
- Bag does not respect the collection API and do an
JVM instance comparison to do the equals.
The semantic is broken not to have to initialize a
collection for a simple equals() operation.
- Specified by:
equalsin interfacejava.util.List
hashCode
public int hashCode()
- Description copied from interface:
java.util.List - Obtains a hash code for this list. In order to obey the general
contract of the hashCode method of class Object, this value is
calculated as follows:
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode()); }This ensures that the general contract of Object.hashCode() is adhered to.
- Specified by:
hashCodein interfacejava.util.List
|
|||||||||
| Home >> All >> org >> hibernate >> [ collection overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC