类 AbstractPersistentCollection
- java.lang.Object
-
- org.hibernate.collection.internal.AbstractPersistentCollection
-
- 所有已实现的接口:
Serializable,PersistentCollection
- 直接已知子类:
PersistentArrayHolder,PersistentBag,PersistentIdentifierBag,PersistentList,PersistentMap,PersistentSet
public abstract class AbstractPersistentCollection extends Object implements Serializable, PersistentCollection
Base class implementingPersistentCollection- 作者:
- Gavin King
- 另请参阅:
- 序列化表格
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected classAbstractPersistentCollection.AbstractValueDelayedOperationprotected static interfaceAbstractPersistentCollection.DelayedOperationContract for operations which are part of a collection's operation queue.protected classAbstractPersistentCollection.IteratorProxystatic interfaceAbstractPersistentCollection.LazyInitializationWork<T>TBH not sure why this is publicprotected classAbstractPersistentCollection.ListIteratorProxyprotected classAbstractPersistentCollection.ListProxyprotected classAbstractPersistentCollection.SetProxyprotected static interfaceAbstractPersistentCollection.ValueDelayedOperation
-
字段概要
字段 修饰符和类型 字段 说明 protected booleanelementRemovedprotected static ObjectUNKNOWN
-
构造器概要
构造器 限定符 构造器 说明 AbstractPersistentCollection()Not called by Hibernate, but used by non-JDK serialization, eg.protectedAbstractPersistentCollection(SessionImplementor session)已过时。protectedAbstractPersistentCollection(SharedSessionContractImplementor session)
-
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 已过时的方法 修饰符和类型 方法 说明 booleanafterInitialize()Called after initializing from cachevoidafterRowInsert(CollectionPersister persister, Object entry, int i)Called after inserting a row, to fetch the natively generated idvoidbeginRead()Called just before reading any rows from the JDBC result setvoidclearDirty()Clear the dirty flag, after flushing changes to the database.voidclearOperationQueue()voiddirty()Mark the collection as dirtyabstract booleanempty()Is the collection empty?booleanendRead()Called after reading all rows from the JDBC result setvoidforceInitialization()To be called internally by the session, forcing immediate initialization.protected intgetCachedSize()ObjectgetIdentifier(Object entry, int i)Get the identifier of the given collection entry.SerializablegetKey()Get the current collection key valueabstract CollectiongetOrphans(Serializable snapshot, String entityName)get all "orphaned" elementsprotected static CollectiongetOrphans(Collection oldElements, Collection currentElements, String entityName, SharedSessionContractImplementor session)Given a collection of entity instances that used to belong to the collection, and a collection of instances that currently belong, return a collection of orphansObjectgetOwner()Get the owning entity.CollectiongetQueuedOrphans(String entityName)Get the "queued" orphansStringgetRole()Get the current role nameSharedSessionContractImplementorgetSession()Get the session currently associated with this collection.protected SerializablegetSnapshot()Get the current snapshot from the sessionSerializablegetStoredSnapshot()Get the snapshot cached by the collection instanceObjectgetValue()Return the user-visible collection (or array) instancebooleanhasQueuedOperations()Does this instance have any "queued" operations?static voididentityRemove(Collection list, Object entityInstance, String entityName, SessionImplementor session)已过时。identityRemove(Collection, Object, String, SharedSessionContractImplementor)should be used instead.static voididentityRemove(Collection list, Object entityInstance, String entityName, SharedSessionContractImplementor session)Removes entity entries that have an equal identifier with the incoming entity instanceprotected voidinitialize(boolean writing)Initialize the collection, if possible, wrapping any exceptions in a runtime exceptionprotected booleanisClearQueueEnabled()Is this collection in a state that would allow us to "queue" clear?protected booleanisConnectedToSession()booleanisDirectlyAccessible()Could the application possibly have a direct reference to the underlying collection implementation?booleanisDirty()Is the collection dirty?booleanisElementRemoved()protected booleanisInitialized()protected booleanisInverseCollection()Is this the "inverse" end of a bidirectional association?protected booleanisInverseCollectionNoOrphanDelete()Is this the "inverse" end of a bidirectional association with no orphan delete enabled?protected booleanisInverseOneToManyOrNoOrphanDelete()Is this the "inverse" end of a bidirectional one-to-many, or of a collection with no orphan delete?protected booleanisOperationQueueEnabled()Is this collection in a state that would allow us to "queue" operations?protected booleanisPutQueueEnabled()Is this collection in a state that would allow us to "queue" puts?booleanisRowUpdatePossible()Can each element in the collection be mapped unequivocally to a single row in the database?booleanisUnreferenced()Is the collection unreferenced?booleanneedsRecreate(CollectionPersister persister)Do we need to completely recreate this collection when it changes?protected voidperformQueuedOperations()After reading all existing elements from the database, add the queued elements to the underlying collection.voidpostAction()After flushing, clear any "queued" additions, since the database state is now synchronized with the memory state.voidpreInsert(CollectionPersister persister)Called before inserting rows, to ensure that any surrogate keys are fully generatedprotected voidprepareForPossibleLoadingOutsideTransaction()IteratorqueuedAdditionIterator()Iterator over the "queued" additionsprotected voidqueueOperation(AbstractPersistentCollection.DelayedOperation operation)Queue an additionprotected voidread()Called by any read-only method of the collection interfaceprotected ObjectreadElementByIndex(Object index)protected BooleanreadElementExistence(Object element)protected BooleanreadIndexExistence(Object index)protected booleanreadSize()Called by theCollection.size()methodvoidreplaceQueuedOperationValues(CollectionPersister persister, Map copyCache)Replace entity instances with copy incopyCache/.booleansetCurrentSession(SharedSessionContractImplementor session)Associate the collection with the given session.protected voidsetDirectlyAccessible(boolean directlyAccessible)protected voidsetInitialized()voidsetOwner(Object owner)Set the reference to the owning entityvoidsetSnapshot(Serializable key, String role, Serializable snapshot)After flushing, re-init snapshot state.booleanunsetSession(SharedSessionContractImplementor currentSession)Disassociate this collection from the given session.booleanwasInitialized()Is this instance initialized?protected voidwrite()Called by any writer method of the collection interface-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 org.hibernate.collection.spi.PersistentCollection
beforeInitialize, disassemble, entries, entryExists, equalsSnapshot, getDeletes, getElement, getIndex, getSnapshot, getSnapshotElement, initializeFromCache, isDirectlyProvidedCollection, isSnapshotEmpty, isWrapper, needsInserting, needsUpdating, readFrom
-
-
-
-
字段详细资料
-
elementRemoved
protected boolean elementRemoved
-
UNKNOWN
protected static final Object UNKNOWN
-
-
构造器详细资料
-
AbstractPersistentCollection
public AbstractPersistentCollection()
Not called by Hibernate, but used by non-JDK serialization, eg. SOAP libraries.
-
AbstractPersistentCollection
protected AbstractPersistentCollection(SharedSessionContractImplementor session)
-
AbstractPersistentCollection
@Deprecated protected AbstractPersistentCollection(SessionImplementor session)
已过时。* @deprecatedAbstractPersistentCollection(SharedSessionContractImplementor)should be used instead.
-
-
方法详细资料
-
getRole
public final String getRole()
从接口复制的说明:PersistentCollectionGet the current role name- 指定者:
getRole在接口中PersistentCollection- 返回:
- the collection role name
-
getKey
public final Serializable getKey()
从接口复制的说明:PersistentCollectionGet the current collection key value- 指定者:
getKey在接口中PersistentCollection- 返回:
- the current collection key value
-
isUnreferenced
public final boolean isUnreferenced()
从接口复制的说明:PersistentCollectionIs the collection unreferenced?- 指定者:
isUnreferenced在接口中PersistentCollection- 返回:
trueif the collection is no longer referenced by an owner
-
isDirty
public final boolean isDirty()
从接口复制的说明:PersistentCollectionIs the collection dirty? Note that this is only reliable during the flush cycle, after the collection elements are dirty checked against the snapshot.- 指定者:
isDirty在接口中PersistentCollection- 返回:
trueif the collection is dirty
-
isElementRemoved
public boolean isElementRemoved()
- 指定者:
isElementRemoved在接口中PersistentCollection
-
clearDirty
public final void clearDirty()
从接口复制的说明:PersistentCollectionClear the dirty flag, after flushing changes to the database.- 指定者:
clearDirty在接口中PersistentCollection
-
dirty
public final void dirty()
从接口复制的说明:PersistentCollectionMark the collection as dirty- 指定者:
dirty在接口中PersistentCollection
-
getStoredSnapshot
public final Serializable getStoredSnapshot()
从接口复制的说明:PersistentCollectionGet the snapshot cached by the collection instance- 指定者:
getStoredSnapshot在接口中PersistentCollection- 返回:
- The internally stored snapshot state
-
empty
public abstract boolean empty()
从接口复制的说明:PersistentCollectionIs the collection empty? (don't try to initialize the collection)- 指定者:
empty在接口中PersistentCollection- 返回:
falseif the collection is non-empty;trueotherwise.
-
read
protected final void read()
Called by any read-only method of the collection interface
-
readSize
protected boolean readSize()
Called by theCollection.size()method
-
getCachedSize
protected int getCachedSize()
-
isConnectedToSession
protected boolean isConnectedToSession()
-
isInitialized
protected boolean isInitialized()
-
write
protected final void write()
Called by any writer method of the collection interface
-
isOperationQueueEnabled
protected boolean isOperationQueueEnabled()
Is this collection in a state that would allow us to "queue" operations?
-
isPutQueueEnabled
protected boolean isPutQueueEnabled()
Is this collection in a state that would allow us to "queue" puts? This is a special case, because of orphan delete.
-
isClearQueueEnabled
protected boolean isClearQueueEnabled()
Is this collection in a state that would allow us to "queue" clear? This is a special case, because of orphan delete.
-
isInverseCollection
protected boolean isInverseCollection()
Is this the "inverse" end of a bidirectional association?
-
isInverseCollectionNoOrphanDelete
protected boolean isInverseCollectionNoOrphanDelete()
Is this the "inverse" end of a bidirectional association with no orphan delete enabled?
-
isInverseOneToManyOrNoOrphanDelete
protected boolean isInverseOneToManyOrNoOrphanDelete()
Is this the "inverse" end of a bidirectional one-to-many, or of a collection with no orphan delete?
-
queueOperation
protected final void queueOperation(AbstractPersistentCollection.DelayedOperation operation)
Queue an addition
-
replaceQueuedOperationValues
public final void replaceQueuedOperationValues(CollectionPersister persister, Map copyCache)
Replace entity instances with copy incopyCache/.- 参数:
copyCache- - mapping from entity in the process of being merged to managed copy.
-
performQueuedOperations
protected final void performQueuedOperations()
After reading all existing elements from the database, add the queued elements to the underlying collection.
-
setSnapshot
public void setSnapshot(Serializable key, String role, Serializable snapshot)
从接口复制的说明:PersistentCollectionAfter flushing, re-init snapshot state.- 指定者:
setSnapshot在接口中PersistentCollection- 参数:
key- The collection instance key (fk value).role- The collection rolesnapshot- The snapshot state
-
postAction
public void postAction()
从接口复制的说明:PersistentCollectionAfter flushing, clear any "queued" additions, since the database state is now synchronized with the memory state.- 指定者:
postAction在接口中PersistentCollection
-
clearOperationQueue
public final void clearOperationQueue()
-
getValue
public Object getValue()
从接口复制的说明:PersistentCollectionReturn the user-visible collection (or array) instance- 指定者:
getValue在接口中PersistentCollection- 返回:
- The underlying collection/array
-
beginRead
public void beginRead()
从接口复制的说明:PersistentCollectionCalled just before reading any rows from the JDBC result set- 指定者:
beginRead在接口中PersistentCollection
-
endRead
public boolean endRead()
从接口复制的说明:PersistentCollectionCalled after reading all rows from the JDBC result set- 指定者:
endRead在接口中PersistentCollection- 返回:
- Whether to end the read.
-
afterInitialize
public boolean afterInitialize()
从接口复制的说明:PersistentCollectionCalled after initializing from cache- 指定者:
afterInitialize在接口中PersistentCollection- 返回:
- ??
-
initialize
protected final void initialize(boolean writing)
Initialize the collection, if possible, wrapping any exceptions in a runtime exception- 参数:
writing- currently obsolete- 抛出:
LazyInitializationException- if we cannot initialize
-
setInitialized
protected final void setInitialized()
-
setDirectlyAccessible
protected final void setDirectlyAccessible(boolean directlyAccessible)
-
isDirectlyAccessible
public boolean isDirectlyAccessible()
从接口复制的说明:PersistentCollectionCould the application possibly have a direct reference to the underlying collection implementation?- 指定者:
isDirectlyAccessible在接口中PersistentCollection- 返回:
trueindicates that the application might have access to the underlying collection/array.
-
unsetSession
public final boolean unsetSession(SharedSessionContractImplementor currentSession)
从接口复制的说明:PersistentCollectionDisassociate this collection from the given session.- 指定者:
unsetSession在接口中PersistentCollection- 参数:
currentSession- The session we are disassociating from. Used for validations.- 返回:
- true if this was currently associated with the given session
-
prepareForPossibleLoadingOutsideTransaction
protected void prepareForPossibleLoadingOutsideTransaction()
-
setCurrentSession
public final boolean setCurrentSession(SharedSessionContractImplementor session) throws HibernateException
从接口复制的说明:PersistentCollectionAssociate the collection with the given session.- 指定者:
setCurrentSession在接口中PersistentCollection- 参数:
session- The session to associate with- 返回:
- false if the collection was already associated with the session
- 抛出:
HibernateException- if the collection was already associated with another open session
-
needsRecreate
public boolean needsRecreate(CollectionPersister persister)
从接口复制的说明:PersistentCollectionDo we need to completely recreate this collection when it changes?- 指定者:
needsRecreate在接口中PersistentCollection- 参数:
persister- The collection persister- 返回:
trueif a change requires a recreate.
-
forceInitialization
public final void forceInitialization() throws HibernateException从接口复制的说明:PersistentCollectionTo be called internally by the session, forcing immediate initialization.- 指定者:
forceInitialization在接口中PersistentCollection- 抛出:
HibernateException
-
getSnapshot
protected final Serializable getSnapshot()
Get the current snapshot from the session
-
wasInitialized
public final boolean wasInitialized()
从接口复制的说明:PersistentCollectionIs this instance initialized?- 指定者:
wasInitialized在接口中PersistentCollection- 返回:
- Was this collection initialized? Or is its data still not (fully) loaded?
-
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- 返回:
trueif the row for each element is known
-
hasQueuedOperations
public final boolean hasQueuedOperations()
从接口复制的说明:PersistentCollectionDoes this instance have any "queued" operations?- 指定者:
hasQueuedOperations在接口中PersistentCollection- 返回:
trueindicates there are pending, queued, delayed operations
-
queuedAdditionIterator
public final Iterator queuedAdditionIterator()
从接口复制的说明:PersistentCollectionIterator over the "queued" additions- 指定者:
queuedAdditionIterator在接口中PersistentCollection- 返回:
- The iterator
-
getQueuedOrphans
public final Collection getQueuedOrphans(String entityName)
从接口复制的说明:PersistentCollectionGet the "queued" orphans- 指定者:
getQueuedOrphans在接口中PersistentCollection- 参数:
entityName- The name of the entity that makes up the elements- 返回:
- The orphaned elements
-
preInsert
public void preInsert(CollectionPersister persister) throws HibernateException
从接口复制的说明:PersistentCollectionCalled before inserting rows, to ensure that any surrogate keys are fully generated- 指定者:
preInsert在接口中PersistentCollection- 参数:
persister- The collection persister- 抛出:
HibernateException
-
afterRowInsert
public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException
从接口复制的说明:PersistentCollectionCalled after inserting a row, to fetch the natively generated id- 指定者:
afterRowInsert在接口中PersistentCollection- 参数:
persister- The collection persisterentry- The collection element just insertedi- The element position/index- 抛出:
HibernateException
-
getOrphans
public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException
从接口复制的说明:PersistentCollectionget all "orphaned" elements- 指定者:
getOrphans在接口中PersistentCollection- 参数:
snapshot- The snapshot stateentityName- The name of the entity that are the elements of the collection- 返回:
- The orphans
- 抛出:
HibernateException
-
getSession
public final SharedSessionContractImplementor getSession()
Get the session currently associated with this collection.- 返回:
- The session
-
getOrphans
protected static Collection getOrphans(Collection oldElements, Collection currentElements, String entityName, SharedSessionContractImplementor session) throws HibernateException
Given a collection of entity instances that used to belong to the collection, and a collection of instances that currently belong, return a collection of orphans
-
identityRemove
public static void identityRemove(Collection list, Object entityInstance, String entityName, SharedSessionContractImplementor session)
Removes entity entries that have an equal identifier with the incoming entity instance- 参数:
list- The list containing the entity instancesentityInstance- The entity instance to match elements.entityName- The entity namesession- The session
-
identityRemove
@Deprecated public static void identityRemove(Collection list, Object entityInstance, String entityName, SessionImplementor session)
已过时。identityRemove(Collection, Object, String, SharedSessionContractImplementor)should be used instead.Removes entity entries that have an equal identifier with the incoming entity instance- 参数:
list- The list containing the entity instancesentityInstance- The entity instance to match elements.entityName- The entity namesession- The session
-
getIdentifier
public Object getIdentifier(Object entry, int i)
从接口复制的说明:PersistentCollectionGet the identifier of the given collection entry. This refers to the collection identifier, not the identifier of the (possibly) entity elements. This is only valid for invocation on theidbagcollection.- 指定者:
getIdentifier在接口中PersistentCollection- 参数:
entry- The collection entry/elementi- The assumed identifier (?)- 返回:
- The identifier value
-
getOwner
public Object getOwner()
从接口复制的说明:PersistentCollectionGet the owning entity. Note that the owner is only set during the flush cycle, and when a new collection wrapper is created while loading an entity.- 指定者:
getOwner在接口中PersistentCollection- 返回:
- The owner
-
setOwner
public void setOwner(Object owner)
从接口复制的说明:PersistentCollectionSet the reference to the owning entity- 指定者:
setOwner在接口中PersistentCollection- 参数:
owner- The owner
-
-