类 PersistentBag
- java.lang.Object
-
- org.hibernate.collection.internal.AbstractPersistentCollection
-
- org.hibernate.collection.internal.PersistentBag
-
- 所有已实现的接口:
Serializable,Iterable,Collection,List,PersistentCollection
public class PersistentBag extends AbstractPersistentCollection implements List
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.- 作者:
- Gavin King
- 另请参阅:
- 序列化表格
-
-
嵌套类概要
-
从类继承的嵌套类/接口 org.hibernate.collection.internal.AbstractPersistentCollection
AbstractPersistentCollection.AbstractValueDelayedOperation, AbstractPersistentCollection.DelayedOperation, AbstractPersistentCollection.IteratorProxy, AbstractPersistentCollection.LazyInitializationWork<T>, AbstractPersistentCollection.ListIteratorProxy, AbstractPersistentCollection.ListProxy, AbstractPersistentCollection.SetProxy, AbstractPersistentCollection.ValueDelayedOperation
-
-
字段概要
字段 修饰符和类型 字段 说明 protected Listbag-
从类继承的字段 org.hibernate.collection.internal.AbstractPersistentCollection
elementRemoved, UNKNOWN
-
-
构造器概要
构造器 构造器 说明 PersistentBag()Constructs a PersistentBag.PersistentBag(SessionImplementor session)已过时。PersistentBag(SharedSessionContractImplementor)should be used instead.PersistentBag(SessionImplementor session, Collection coll)已过时。PersistentBag(SharedSessionContractImplementor, Collection)should be used instead.PersistentBag(SharedSessionContractImplementor session)Constructs a PersistentBagPersistentBag(SharedSessionContractImplementor session, Collection coll)Constructs a PersistentBag
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidadd(int i, Object o)booleanadd(Object object)booleanaddAll(int i, Collection c)booleanaddAll(Collection values)voidbeforeInitialize(CollectionPersister persister, int anticipatedSize)Called before any elements are read into the collection, allowing appropriate initializations to occur.voidclear()booleancontains(Object object)booleancontainsAll(Collection c)Serializabledisassemble(CollectionPersister persister)Disassemble the collection to get it ready for the cachebooleanempty()Is the collection empty?Iteratorentries(CollectionPersister persister)Iterate all collection entries, during update of the databasebooleanentryExists(Object entry, int i)Does the given element/entry exist in the collection?booleanequals(Object obj)Bag does not respect the collection API and do an JVM instance comparison to do the equals.booleanequalsSnapshot(CollectionPersister persister)Does the current state exactly match the snapshot?Objectget(int i)IteratorgetDeletes(CollectionPersister persister, boolean indexIsFormula)Get all the elements that need deletingObjectgetElement(Object entry)Get the value of the given collection entry.ObjectgetIndex(Object entry, int i, CollectionPersister persister)Get the index of the given collection entryCollectiongetOrphans(Serializable snapshot, String entityName)get all "orphaned" elementsSerializablegetSnapshot(CollectionPersister persister)Return a new snapshot of the current state of the collectionObjectgetSnapshotElement(Object entry, int i)Get the snapshot value of the given collection entryinthashCode()intindexOf(Object o)voidinitializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)Read the state of the collection from a disassembled cached valuebooleanisDirectlyProvidedCollection(Object collection)Wascollectionprovided directly to this PersistentCollection (i.e., provided as an argument to a constructor)?booleanisEmpty()booleanisRowUpdatePossible()Can each element in the collection be mapped unequivocally to a single row in the database?booleanisSnapshotEmpty(Serializable snapshot)Is the snapshot empty?booleanisWrapper(Object collection)Is this the wrapper for the given collection instance?Iteratoriterator()intlastIndexOf(Object o)ListIteratorlistIterator()ListIteratorlistIterator(int i)booleanneedsInserting(Object entry, int i, Type elemType)Do we need to insert this element?booleanneedsRecreate(CollectionPersister persister)Do we need to completely recreate this collection when it changes?booleanneedsUpdating(Object entry, int i, Type elemType)Do we need to update this element?intoccurrences(Object o)Count how many times the given object occurs in the elementsObjectreadFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)Read a row from the JDBC result setObjectremove(int i)booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)Objectset(int i, Object o)intsize()ListsubList(int start, int end)Object[]toArray()Object[]toArray(Object[] a)StringtoString()-
从类继承的方法 org.hibernate.collection.internal.AbstractPersistentCollection
afterInitialize, afterRowInsert, beginRead, clearDirty, clearOperationQueue, dirty, endRead, forceInitialization, getCachedSize, getIdentifier, getKey, getOrphans, getOwner, getQueuedOrphans, getRole, getSession, getSnapshot, getStoredSnapshot, getValue, hasQueuedOperations, identityRemove, identityRemove, initialize, isClearQueueEnabled, isConnectedToSession, isDirectlyAccessible, isDirty, isElementRemoved, isInitialized, isInverseCollection, isInverseCollectionNoOrphanDelete, isInverseOneToManyOrNoOrphanDelete, isOperationQueueEnabled, isPutQueueEnabled, isUnreferenced, performQueuedOperations, postAction, preInsert, prepareForPossibleLoadingOutsideTransaction, queuedAdditionIterator, queueOperation, read, readElementByIndex, readElementExistence, readIndexExistence, readSize, replaceQueuedOperationValues, setCurrentSession, setDirectlyAccessible, setInitialized, setOwner, setSnapshot, unsetSession, wasInitialized, write
-
从接口继承的方法 java.util.Collection
parallelStream, removeIf, stream, toArray
-
从接口继承的方法 java.util.List
replaceAll, sort, spliterator
-
-
-
-
字段详细资料
-
bag
protected List bag
-
-
构造器详细资料
-
PersistentBag
public PersistentBag()
Constructs a PersistentBag. Needed for SOAP libraries, etc
-
PersistentBag
public PersistentBag(SharedSessionContractImplementor session)
Constructs a PersistentBag- 参数:
session- The session
-
PersistentBag
@Deprecated public PersistentBag(SessionImplementor session)
已过时。PersistentBag(SharedSessionContractImplementor)should be used instead.Constructs a PersistentBag- 参数:
session- The session
-
PersistentBag
public PersistentBag(SharedSessionContractImplementor session, Collection coll)
Constructs a PersistentBag- 参数:
session- The sessioncoll- The base elements.
-
PersistentBag
@Deprecated public PersistentBag(SessionImplementor session, Collection coll)
已过时。PersistentBag(SharedSessionContractImplementor, Collection)should be used instead.Constructs a PersistentBag- 参数:
session- The sessioncoll- The base elements.
-
-
方法详细资料
-
isWrapper
public boolean isWrapper(Object collection)
从接口复制的说明:PersistentCollectionIs this the wrapper for the given collection instance?- 指定者:
isWrapper在接口中PersistentCollection- 参数:
collection- The collection to check whether this is wrapping it- 返回:
trueif this is a wrapper around that given collection instance.
-
isDirectlyProvidedCollection
public boolean isDirectlyProvidedCollection(Object collection)
从接口复制的说明:PersistentCollectionWascollectionprovided directly to this PersistentCollection (i.e., provided as an argument to a constructor)? Implementors that can copy elements out of a directly provided collection into the wrapped collection should override this method.- 指定者:
isDirectlyProvidedCollection在接口中PersistentCollection- 参数:
collection- The collection- 返回:
- true, if
collectionwas provided directly to this PersistentCollection; false, otherwise.
-
empty
public boolean empty()
从接口复制的说明:PersistentCollectionIs the collection empty? (don't try to initialize the collection)- 指定者:
empty在接口中PersistentCollection- 指定者:
empty在类中AbstractPersistentCollection- 返回:
falseif the collection is non-empty;trueotherwise.
-
entries
public Iterator entries(CollectionPersister persister)
从接口复制的说明:PersistentCollectionIterate all collection entries, during update of the database- 指定者:
entries在接口中PersistentCollection- 参数:
persister- The collection persister.- 返回:
- The iterator
-
readFrom
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner) throws HibernateException, SQLException
从接口复制的说明:PersistentCollectionRead a row from the JDBC result set- 指定者:
readFrom在接口中PersistentCollection- 参数:
rs- The JDBC ResultSetpersister- The collection roledescriptor- The aliases used for the columns making up the collectionowner- The collection owner- 返回:
- The read object
- 抛出:
HibernateException- Generally indicates a problem resolving data read from the ResultSetSQLException- Indicates a problem accessing the ResultSet
-
beforeInitialize
public void beforeInitialize(CollectionPersister persister, int anticipatedSize)
从接口复制的说明:PersistentCollectionCalled before any elements are read into the collection, allowing appropriate initializations to occur.- 指定者:
beforeInitialize在接口中PersistentCollection- 参数:
persister- The underlying collection persister.anticipatedSize- The anticipated size of the collection after initialization is complete.
-
equalsSnapshot
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException
从接口复制的说明:PersistentCollectionDoes the current state exactly match the snapshot?- 指定者:
equalsSnapshot在接口中PersistentCollection- 参数:
persister- The collection persister- 返回:
trueif the current state and the snapshot state match.- 抛出:
HibernateException
-
isSnapshotEmpty
public boolean isSnapshotEmpty(Serializable snapshot)
从接口复制的说明:PersistentCollectionIs the snapshot empty?- 指定者:
isSnapshotEmpty在接口中PersistentCollection- 参数:
snapshot- The snapshot to check- 返回:
trueif the given snapshot is empty
-
getSnapshot
public Serializable getSnapshot(CollectionPersister persister) throws HibernateException
从接口复制的说明:PersistentCollectionReturn a new snapshot of the current state of the collection- 指定者:
getSnapshot在接口中PersistentCollection- 参数:
persister- The collection persister- 返回:
- The snapshot
- 抛出:
HibernateException
-
getOrphans
public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException
从接口复制的说明:PersistentCollectionget all "orphaned" elements- 指定者:
getOrphans在接口中PersistentCollection- 指定者:
getOrphans在类中AbstractPersistentCollection- 参数:
snapshot- The snapshot stateentityName- The name of the entity that are the elements of the collection- 返回:
- The orphans
- 抛出:
HibernateException
-
disassemble
public Serializable disassemble(CollectionPersister persister) throws HibernateException
从接口复制的说明:PersistentCollectionDisassemble the collection to get it ready for the cache- 指定者:
disassemble在接口中PersistentCollection- 参数:
persister- The collection persister- 返回:
- The disassembled state
- 抛出:
HibernateException
-
initializeFromCache
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) throws HibernateException
从接口复制的说明:PersistentCollectionRead the state of the collection from a disassembled cached value- 指定者:
initializeFromCache在接口中PersistentCollection- 参数:
persister- The collection persisterdisassembled- The disassembled cached stateowner- The collection owner- 抛出:
HibernateException
-
needsRecreate
public boolean needsRecreate(CollectionPersister persister)
从接口复制的说明:PersistentCollectionDo we need to completely recreate this collection when it changes?- 指定者:
needsRecreate在接口中PersistentCollection- 覆盖:
needsRecreate在类中AbstractPersistentCollection- 参数:
persister- The collection persister- 返回:
trueif a change requires a recreate.
-
getDeletes
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException
从接口复制的说明:PersistentCollectionGet all the elements that need deleting- 指定者:
getDeletes在接口中PersistentCollection- 参数:
persister- The collection persisterindexIsFormula- For indexed collections, tells whether the index is a formula (calculated value) mapping- 返回:
- An iterator over the elements to delete
- 抛出:
HibernateException
-
needsInserting
public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException
从接口复制的说明:PersistentCollectionDo we need to insert this element?- 指定者:
needsInserting在接口中PersistentCollection- 参数:
entry- The collection element to checki- The index (for indexed collections)elemType- The type for the element- 返回:
trueif the element needs inserting- 抛出:
HibernateException
-
isRowUpdatePossible
public boolean isRowUpdatePossible()
从接口复制的说明:PersistentCollectionCan each element in the collection be mapped unequivocally to a single row in the database? Generally bags and sets are the only collections that cannot be.- 指定者:
isRowUpdatePossible在接口中PersistentCollection- 覆盖:
isRowUpdatePossible在类中AbstractPersistentCollection- 返回:
trueif the row for each element is known
-
needsUpdating
public boolean needsUpdating(Object entry, int i, Type elemType)
从接口复制的说明:PersistentCollectionDo we need to update this element?- 指定者:
needsUpdating在接口中PersistentCollection- 参数:
entry- The collection element to checki- The index (for indexed collections)elemType- The type for the element- 返回:
trueif the element needs updating
-
size
public int size()
- 指定者:
size在接口中Collection- 指定者:
size在接口中List
-
isEmpty
public boolean isEmpty()
- 指定者:
isEmpty在接口中Collection- 指定者:
isEmpty在接口中List
-
contains
public boolean contains(Object object)
- 指定者:
contains在接口中Collection- 指定者:
contains在接口中List
-
iterator
public Iterator iterator()
-
toArray
public Object[] toArray()
- 指定者:
toArray在接口中Collection- 指定者:
toArray在接口中List
-
add
public boolean add(Object object)
- 指定者:
add在接口中Collection- 指定者:
add在接口中List
-
remove
public boolean remove(Object o)
- 指定者:
remove在接口中Collection- 指定者:
remove在接口中List
-
containsAll
public boolean containsAll(Collection c)
- 指定者:
containsAll在接口中Collection- 指定者:
containsAll在接口中List
-
addAll
public boolean addAll(Collection values)
- 指定者:
addAll在接口中Collection- 指定者:
addAll在接口中List
-
removeAll
public boolean removeAll(Collection c)
- 指定者:
removeAll在接口中Collection- 指定者:
removeAll在接口中List
-
retainAll
public boolean retainAll(Collection c)
- 指定者:
retainAll在接口中Collection- 指定者:
retainAll在接口中List
-
clear
public void clear()
- 指定者:
clear在接口中Collection- 指定者:
clear在接口中List
-
getIndex
public Object getIndex(Object entry, int i, CollectionPersister persister)
从接口复制的说明:PersistentCollectionGet the index of the given collection entry- 指定者:
getIndex在接口中PersistentCollection- 参数:
entry- The collection entry/elementi- The assumed indexpersister- it was more elegant before we added this...- 返回:
- The index value
-
getElement
public Object getElement(Object entry)
从接口复制的说明:PersistentCollectionGet the value of the given collection entry. Generally the given entry parameter value will just be returned. Might get a different value for a duplicate entries in a Set.- 指定者:
getElement在接口中PersistentCollection- 参数:
entry- The object instance for which to get the collection element instance.- 返回:
- The corresponding object that is part of the collection elements.
-
getSnapshotElement
public Object getSnapshotElement(Object entry, int i)
从接口复制的说明:PersistentCollectionGet the snapshot value of the given collection entry- 指定者:
getSnapshotElement在接口中PersistentCollection- 参数:
entry- The entryi- The index- 返回:
- The snapshot state for that element
-
occurrences
public int occurrences(Object o)
Count how many times the given object occurs in the elements- 参数:
o- The object to check- 返回:
- The number of occurrences.
-
addAll
public boolean addAll(int i, Collection c)
-
lastIndexOf
public int lastIndexOf(Object o)
- 指定者:
lastIndexOf在接口中List
-
listIterator
public ListIterator listIterator()
- 指定者:
listIterator在接口中List
-
listIterator
public ListIterator listIterator(int i)
- 指定者:
listIterator在接口中List
-
entryExists
public boolean entryExists(Object entry, int i)
从接口复制的说明:PersistentCollectionDoes the given element/entry exist in the collection?- 指定者:
entryExists在接口中PersistentCollection- 参数:
entry- The object to check if it exists as a collection elementi- Unused- 返回:
trueif the given entry is a collection element
-
equals
public boolean equals(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.
-
-