类 StatefulPersistenceContext
- java.lang.Object
-
- org.hibernate.engine.internal.StatefulPersistenceContext
-
- 所有已实现的接口:
PersistenceContext
public class StatefulPersistenceContext extends Object implements PersistenceContext
A stateful implementation of thePersistenceContextcontract meaning that we maintain this state throughout the life of the persistence context. IMPL NOTE: There is meant to be a one-to-one correspondence between aSessionImpland a PersistentContext. Event listeners and other Session collaborators then use the PersistentContext to drive their processing.- 作者:
- Steve Ebersole, Sanne Grinovero
-
-
嵌套类概要
-
从接口继承的嵌套类/接口 org.hibernate.engine.spi.PersistenceContext
PersistenceContext.NaturalIdHelper
-
-
字段概要
-
从接口继承的字段 org.hibernate.engine.spi.PersistenceContext
NO_ROW
-
-
构造器概要
构造器 构造器 说明 StatefulPersistenceContext(SharedSessionContractImplementor session)Constructs a PersistentContext, bound to the given session.
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 voidaddChildParent(Object child, Object parent)Add a child/parent relation to cache for cascading opPersistentCollectionaddCollectionByKey(CollectionKey collectionKey, PersistentCollection persistentCollection)Adds a collection in the collections-by-key map.voidaddCollectionHolder(PersistentCollection holder)Register a PersistentCollection object for an array.voidaddEnhancedProxy(EntityKey key, PersistentAttributeInterceptable entity)Cross betweenPersistenceContext.addEntity(EntityKey, Object)andPersistenceContext.addProxy(EntityKey, Object)for use with enhancement-as-proxyEntityEntryaddEntity(Object entity, Status status, Object[] loadedState, EntityKey entityKey, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)Adds an entity to the internal caches.voidaddEntity(EntityKey key, Object entity)Add a canonical mapping from entity key to entity instancevoidaddEntity(EntityUniqueKey euk, Object entity)Add an entity to the cache by unique keyEntityEntryaddEntry(Object entity, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.CollectionEntryaddInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)add a collection we just pulled out of the cache (does not need initializing)voidaddInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection)add an (initialized) collection that was created by another session and passed into update() (ie. one with a snapshot and existing state on the database)voidaddNewCollection(CollectionPersister persister, PersistentCollection collection)Add a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)voidaddNonLazyCollection(PersistentCollection collection)Register a collection for non-lazy loading at the end of the two-phase loadvoidaddNullProperty(EntityKey ownerKey, String propertyName)Record the fact that the association belonging to the keyed entity is null.voidaddProxy(EntityKey key, Object proxy)Add a proxy to the session cacheEntityEntryaddReferenceEntry(Object entity, Status status)voidaddUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)add a collection we just loaded up (still needs initializing)voidaddUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection)add a detached uninitialized collectionvoidaddUnownedCollection(CollectionKey key, PersistentCollection collection)Add a collection which has no owner loadedvoidafterLoad()Call this after finishing a two-phase loadvoidafterTransactionCompletion()Called after transactions endvoidbeforeLoad()Call this before beginning a two-phase loadvoidbeginRemoveOrphanBeforeUpdates()voidcheckUniqueness(EntityKey key, Object object)Attempts to check whether the given key represents an entity already loaded within the current session.voidclear()Clear the state of the persistence contextvoidclearCollectionsByKey()Remove all state of the collections-by-key map.booleancontainsCollection(PersistentCollection collection)Is the given collection associated with this persistence context?booleancontainsEntity(EntityKey key)Is there an entity with the given key in the persistence contextbooleancontainsNullifiableEntityKey(Supplier<EntityKey> sek)Checks if a certainEntityKeywas registered as nullifiable on thisPersistenceContext.booleancontainsProxy(Object entity)Is the given proxy associated with this persistence context?intdecrementCascadeLevel()Called after cascadingstatic StatefulPersistenceContextdeserialize(ObjectInputStream ois, SessionImplementor session)Used by the owning session to explicitly control deserialization of the persistence context.voidendRemoveOrphanBeforeUpdates()voidforEachCollectionEntry(BiConsumer<PersistentCollection,CollectionEntry> action, boolean concurrent)Execute some action on each entry of the collectionEntries map, optionally iterating on a defensive copy.BatchFetchQueuegetBatchFetchQueue()Get theBatchFetchQueue, instantiating one if necessary.Object[]getCachedDatabaseSnapshot(EntityKey key)Retrieve the cached database snapshot for the requested entity key.intgetCascadeLevel()How deep are we cascaded?PersistentCollectiongetCollection(CollectionKey collectionKey)Get the collection instance associated with the CollectionKeyMapgetCollectionEntries()已过时。We should not expose this directly: the other accessors that have been created as a replacement have better chances of skipping initializing this map, which is a good performance improvement.intgetCollectionEntriesSize()The size of the internal map storing all collection entries.CollectionEntrygetCollectionEntry(PersistentCollection coll)Get the collection entry for a persistent collectionCollectionEntrygetCollectionEntryOrNull(Object collection)Get the collection entry for a collection passed to filter, which might be a collection wrapper, an array, or an unwrapped collection.PersistentCollectiongetCollectionHolder(Object array)Get the PersistentCollection object for an arrayObjectgetCollectionOwner(Serializable key, CollectionPersister collectionPersister)Get the entity that owns this persistent collectionMapgetCollectionsByKey()Get the mapping from collection key to collection instanceObject[]getDatabaseSnapshot(Serializable id, EntityPersister persister)Get the current state of the entity as known to the underlying database, or null if there is no corresponding rowMapgetEntitiesByKey()已过时。this will be removed: it provides too wide access, making it hard to optimise the internals for specific access needs.ObjectgetEntity(EntityKey key)Get the entity instance associated with the given keyObjectgetEntity(EntityUniqueKey euk)Get an entity cached by unique keyMapgetEntityEntries()Get the mapping from entity instance to entity entryEntityEntrygetEntry(Object entity)Retrieve theEntityEntryrepresentation of the given entity.ObjectgetIndexInOwner(String entity, String property, Object childEntity, Map mergeMap)Search the persistence context for an index of the child object, given a collection roleLoadContextsgetLoadContexts()Retrieve this persistence context's managed load context.SerializablegetLoadedCollectionOwnerIdOrNull(PersistentCollection collection)Get the ID for the entity that owned this persistent collection when it was loadedObjectgetLoadedCollectionOwnerOrNull(PersistentCollection collection)Get the entity that owned this persistent collection when it was loadedPersistenceContext.NaturalIdHelpergetNaturalIdHelper()Access to the natural-id helper for this persistence contextObject[]getNaturalIdSnapshot(Serializable id, EntityPersister persister)Get the values of the natural id fields as known to the underlying database, or null if the entity has no natural id or there is no corresponding row.HashSetgetNullifiableEntityKeys()Retrieve the set of EntityKeys representing nullifiable referencesintgetNumberOfManagedEntities()SerializablegetOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap)Search this persistence context for an associated entity instance which is considered the "owner" of the given childEntity, and return that owner's id value.ObjectgetProxy(EntityKey key)Get an existing proxy by keySharedSessionContractImplementorgetSession()Get the session to which this persistence context is bound.SerializablegetSnapshot(PersistentCollection coll)Get the snapshot of the pre-flush collection statebooleanhasNonReadOnlyEntities()intincrementCascadeLevel()Called before cascadingvoidinitializeNonLazyCollections()Force initialization of all non-lazy collections encountered during the current two-phase load (actually, this is a no-op, unless this is the "outermost" load)booleanisDefaultReadOnly()Will entities and proxies that are loaded into this persistence context be made read-only by default?booleanisEntryFor(Object entity)Is there anEntityEntryregistration for this entity instance?booleanisFlushing()Is a flush cycle currently in process?booleanisLoadFinished()Is in a two-phase load?booleanisNullifiableEntityKeysEmpty()booleanisPropertyNull(EntityKey ownerKey, String propertyName)Is the association property belonging to the keyed entity null?booleanisReadOnly(Object entityOrProxy)Is the entity or proxy read-only?booleanisRemovingOrphanBeforeUpates()booleanisStateless()IteratormanagedEntitiesIterator()A read-only iterator on all entities managed by this persistence contextObjectnarrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy and overwrite the registration of the old one.ObjectproxyFor(Object impl)Return the existing proxy associated with the given EntityKey, or the argument (the entity associated with the key) if no proxy exists.ObjectproxyFor(EntityPersister persister, EntityKey key, Object impl)Return the existing proxy associated with the given EntityKey, or the third argument (the entity associated with the key) if no proxy exists.booleanreassociateIfUninitializedProxy(Object value)Takes the given object and, if it represents a proxy, reassociates it with this event source.voidreassociateProxy(Object value, Serializable id)If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxyMap.Entry<Object,EntityEntry>[]reentrantSafeEntityEntries()Provides access to the entity/EntityEntry combos associated with the persistence context in a manner that is safe from reentrant access.voidregisterInsertedKey(EntityPersister persister, Serializable id)Register keys inserted during the current transactionvoidregisterNullifiableEntityKey(EntityKey key)Registers anEntityKeyas nullifiable on thisPersistenceContext.voidremoveChildParent(Object child)Remove child/parent relation from cachevoidremoveCollectionByKey(CollectionKey collectionKey)Remove a collection-by-key mapping.CollectionEntryremoveCollectionEntry(PersistentCollection collection)Remove aPersistentCollectionfrom thePersistenceContext.PersistentCollectionremoveCollectionHolder(Object array)Remove the mapping of collection to holder during eviction of the owning entityObjectremoveEntity(EntityKey key)Remove an entity.EntityEntryremoveEntry(Object entity)Remove an entity entry from the session cacheObjectremoveProxy(EntityKey key)Remove a proxy from the session cache.voidreplaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId)voidserialize(ObjectOutputStream oos)Used by the owning session to explicitly control serialization of the persistence context.voidsetDefaultReadOnly(boolean defaultReadOnly)Change the default for entities and proxies loaded into this persistence context from modifiable to read-only mode, or from modifiable to read-only mode.voidsetEntryStatus(EntityEntry entry, Status status)Set the status of an entryvoidsetFlushing(boolean flushing)Called before and after the flush cyclevoidsetReadOnly(Object object, boolean readOnly)Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.StringtoString()Returns a string representation of the object.Objectunproxy(Object maybeProxy)Get the entity instance underlying the given proxy, throwing an exception if the proxy is uninitialized.ObjectunproxyAndReassociate(Object maybeProxy)Possibly unproxy the given reference and reassociate it with the current session.PersistentCollectionuseUnownedCollection(CollectionKey key)Take ownership of a previously unowned collection, if one.booleanwasInsertedDuringTransaction(EntityPersister persister, Serializable id)Allows callers to check to see if the identified entity was inserted during the current transaction.
-
-
-
构造器详细资料
-
StatefulPersistenceContext
public StatefulPersistenceContext(SharedSessionContractImplementor session)
Constructs a PersistentContext, bound to the given session.- 参数:
session- The session "owning" this context.
-
-
方法详细资料
-
isStateless
public boolean isStateless()
- 指定者:
isStateless在接口中PersistenceContext
-
getSession
public SharedSessionContractImplementor getSession()
从接口复制的说明:PersistenceContextGet the session to which this persistence context is bound.- 指定者:
getSession在接口中PersistenceContext- 返回:
- The session.
-
getLoadContexts
public LoadContexts getLoadContexts()
从接口复制的说明:PersistenceContextRetrieve this persistence context's managed load context.- 指定者:
getLoadContexts在接口中PersistenceContext- 返回:
- The load context
-
addUnownedCollection
public void addUnownedCollection(CollectionKey key, PersistentCollection collection)
从接口复制的说明:PersistenceContextAdd a collection which has no owner loaded- 指定者:
addUnownedCollection在接口中PersistenceContext- 参数:
key- The collection key under which to add the collectioncollection- The collection to add
-
useUnownedCollection
public PersistentCollection useUnownedCollection(CollectionKey key)
从接口复制的说明:PersistenceContextTake ownership of a previously unowned collection, if one. This method returnsnullif no such collection was previously added () or was previously removed. This should indicate the owner is being loaded and we are ready to "link" them.- 指定者:
useUnownedCollection在接口中PersistenceContext- 参数:
key- The collection key for which to locate a collection collection- 返回:
- The unowned collection, or
null
-
getBatchFetchQueue
public BatchFetchQueue getBatchFetchQueue()
从接口复制的说明:PersistenceContextGet theBatchFetchQueue, instantiating one if necessary.- 指定者:
getBatchFetchQueue在接口中PersistenceContext- 返回:
- The batch fetch queue in effect for this persistence context
-
clear
public void clear()
从接口复制的说明:PersistenceContextClear the state of the persistence context- 指定者:
clear在接口中PersistenceContext
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
从接口复制的说明:PersistenceContextWill entities and proxies that are loaded into this persistence context be made read-only by default? To determine the read-only/modifiable setting for a particular entity or proxy:- 指定者:
isDefaultReadOnly在接口中PersistenceContext- 返回:
- true, loaded entities/proxies will be made read-only by default; false, loaded entities/proxies will be made modifiable by default.
- 另请参阅:
PersistenceContext.isReadOnly(Object),Session.isReadOnly(Object),Session.isDefaultReadOnly()
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean defaultReadOnly)
从接口复制的说明:PersistenceContextChange the default for entities and proxies loaded into this persistence context from modifiable to read-only mode, or from modifiable to read-only mode. Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the persistence context's current setting. To change the read-only/modifiable setting for a particular entity or proxy that is already in this session: + * @see PersistenceContext#setReadOnly(Object,boolean)- 指定者:
setDefaultReadOnly在接口中PersistenceContext- 参数:
defaultReadOnly- true, the default for loaded entities/proxies is read-only; false, the default for loaded entities/proxies is modifiable- 另请参阅:
To override this session's read-only/modifiable setting for entities and proxies loaded by a Query:,Query.setReadOnly(boolean),Session.setDefaultReadOnly(boolean)
-
hasNonReadOnlyEntities
public boolean hasNonReadOnlyEntities()
- 指定者:
hasNonReadOnlyEntities在接口中PersistenceContext- 返回:
- false if we know for certain that all the entities are read-only
-
setEntryStatus
public void setEntryStatus(EntityEntry entry, Status status)
从接口复制的说明:PersistenceContextSet the status of an entry- 指定者:
setEntryStatus在接口中PersistenceContext- 参数:
entry- The entry for which to set the statusstatus- The new status
-
afterTransactionCompletion
public void afterTransactionCompletion()
从接口复制的说明:PersistenceContextCalled after transactions end- 指定者:
afterTransactionCompletion在接口中PersistenceContext
-
getDatabaseSnapshot
public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister) throws HibernateException
Get the current state of the entity as known to the underlying database, or null if there is no corresponding row Get the current state of the entity as known to the underlying database, or null if there is no corresponding row- 指定者:
getDatabaseSnapshot在接口中PersistenceContext- 参数:
id- The identifier of the entity for which to grab a snapshotpersister- The persister of the entity.- 返回:
- The entity's (non-cached) snapshot
- 抛出:
HibernateException- 另请参阅:
PersistenceContext.getCachedDatabaseSnapshot(org.hibernate.engine.spi.EntityKey)
-
getNaturalIdSnapshot
public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister) throws HibernateException
从接口复制的说明:PersistenceContextGet the values of the natural id fields as known to the underlying database, or null if the entity has no natural id or there is no corresponding row.- 指定者:
getNaturalIdSnapshot在接口中PersistenceContext- 参数:
id- The identifier of the entity for which to grab a snapshotpersister- The persister of the entity.- 返回:
- The current (non-cached) snapshot of the entity's natural id state.
- 抛出:
HibernateException
-
getCachedDatabaseSnapshot
public Object[] getCachedDatabaseSnapshot(EntityKey key)
从接口复制的说明:PersistenceContextRetrieve the cached database snapshot for the requested entity key. This differs fromPersistenceContext.getDatabaseSnapshot(java.io.Serializable, org.hibernate.persister.entity.EntityPersister)in two important respects:- no snapshot is obtained from the database if not already cached
- an entry of
PersistenceContext.NO_ROWhere is interpreted as an exception
- 指定者:
getCachedDatabaseSnapshot在接口中PersistenceContext- 参数:
key- The entity key for which to retrieve the cached snapshot- 返回:
- The cached snapshot
-
addEntity
public void addEntity(EntityKey key, Object entity)
从接口复制的说明:PersistenceContextAdd a canonical mapping from entity key to entity instance- 指定者:
addEntity在接口中PersistenceContext- 参数:
key- The key under which to add an entityentity- The entity instance to add
-
getEntity
public Object getEntity(EntityKey key)
从接口复制的说明:PersistenceContextGet the entity instance associated with the given key- 指定者:
getEntity在接口中PersistenceContext- 参数:
key- The key under which to look for an entity- 返回:
- The matching entity, or
null
-
containsEntity
public boolean containsEntity(EntityKey key)
从接口复制的说明:PersistenceContextIs there an entity with the given key in the persistence context- 指定者:
containsEntity在接口中PersistenceContext- 参数:
key- The key under which to look for an entity- 返回:
trueindicates an entity was found; otherwisefalse
-
removeEntity
public Object removeEntity(EntityKey key)
从接口复制的说明:PersistenceContextRemove an entity. Also clears up all other state associated with the entity aside from theEntityEntry- 指定者:
removeEntity在接口中PersistenceContext- 参数:
key- The key whose matching entity should be removed- 返回:
- The matching entity
-
getEntity
public Object getEntity(EntityUniqueKey euk)
从接口复制的说明:PersistenceContextGet an entity cached by unique key- 指定者:
getEntity在接口中PersistenceContext- 参数:
euk- The unique (non-primary) key under which to look for an entity- 返回:
- The located entity
-
addEntity
public void addEntity(EntityUniqueKey euk, Object entity)
从接口复制的说明:PersistenceContextAdd an entity to the cache by unique key- 指定者:
addEntity在接口中PersistenceContext- 参数:
euk- The unique (non-primary) key under which to add an entityentity- The entity instance
-
getEntry
public EntityEntry getEntry(Object entity)
从接口复制的说明:PersistenceContextRetrieve theEntityEntryrepresentation of the given entity.- 指定者:
getEntry在接口中PersistenceContext- 参数:
entity- The entity instance for which to locate the corresponding entry- 返回:
- The entry
-
removeEntry
public EntityEntry removeEntry(Object entity)
从接口复制的说明:PersistenceContextRemove an entity entry from the session cache- 指定者:
removeEntry在接口中PersistenceContext- 参数:
entity- The entity instance for which to remove the corresponding entry- 返回:
- The matching entry
-
isEntryFor
public boolean isEntryFor(Object entity)
从接口复制的说明:PersistenceContextIs there anEntityEntryregistration for this entity instance?- 指定者:
isEntryFor在接口中PersistenceContext- 参数:
entity- The entity instance for which to check for an entry- 返回:
trueindicates a matching entry was found.
-
getCollectionEntry
public CollectionEntry getCollectionEntry(PersistentCollection coll)
从接口复制的说明:PersistenceContextGet the collection entry for a persistent collection- 指定者:
getCollectionEntry在接口中PersistenceContext- 参数:
coll- The persistent collection instance for which to locate the collection entry- 返回:
- The matching collection entry
-
addEntity
public EntityEntry addEntity(Object entity, Status status, Object[] loadedState, EntityKey entityKey, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)
从接口复制的说明:PersistenceContextAdds an entity to the internal caches.- 指定者:
addEntity在接口中PersistenceContext
-
addEntry
public EntityEntry addEntry(Object entity, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement)
从接口复制的说明:PersistenceContextGenerates an appropriate EntityEntry instance and adds it to the event source's internal caches.- 指定者:
addEntry在接口中PersistenceContext
-
addReferenceEntry
public EntityEntry addReferenceEntry(Object entity, Status status)
-
containsCollection
public boolean containsCollection(PersistentCollection collection)
从接口复制的说明:PersistenceContextIs the given collection associated with this persistence context?- 指定者:
containsCollection在接口中PersistenceContext
-
containsProxy
public boolean containsProxy(Object entity)
从接口复制的说明:PersistenceContextIs the given proxy associated with this persistence context?- 指定者:
containsProxy在接口中PersistenceContext
-
reassociateIfUninitializedProxy
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException
从接口复制的说明:PersistenceContextTakes the given object and, if it represents a proxy, reassociates it with this event source.- 指定者:
reassociateIfUninitializedProxy在接口中PersistenceContext- 参数:
value- The possible proxy to be reassociated.- 返回:
- Whether the passed value represented an actual proxy which got initialized.
- 抛出:
MappingException
-
reassociateProxy
public void reassociateProxy(Object value, Serializable id) throws MappingException
从接口复制的说明:PersistenceContextIf a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy- 指定者:
reassociateProxy在接口中PersistenceContext- 抛出:
MappingException
-
unproxy
public Object unproxy(Object maybeProxy) throws HibernateException
从接口复制的说明:PersistenceContextGet the entity instance underlying the given proxy, throwing an exception if the proxy is uninitialized. If the given object is not a proxy, simply return the argument.- 指定者:
unproxy在接口中PersistenceContext- 抛出:
HibernateException
-
unproxyAndReassociate
public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException
从接口复制的说明:PersistenceContextPossibly unproxy the given reference and reassociate it with the current session.- 指定者:
unproxyAndReassociate在接口中PersistenceContext- 参数:
maybeProxy- The reference to be unproxied if it currently represents a proxy.- 返回:
- The unproxied instance.
- 抛出:
HibernateException
-
checkUniqueness
public void checkUniqueness(EntityKey key, Object object) throws HibernateException
从接口复制的说明:PersistenceContextAttempts to check whether the given key represents an entity already loaded within the current session.- 指定者:
checkUniqueness在接口中PersistenceContextobject- The entity reference against which to perform the uniqueness check.- 抛出:
HibernateException
-
narrowProxy
public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object) throws HibernateException
从接口复制的说明:PersistenceContextIf the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy and overwrite the registration of the old one. This breaks == and occurs only for "class" proxies rather than "interface" proxies. Also init the proxy to point to the given target implementation if necessary.- 指定者:
narrowProxy在接口中PersistenceContext- 参数:
proxy- The proxy instance to be narrowed.persister- The persister for the proxied entity.key- The internal cache key for the proxied entity.object- (optional) the actual proxied entity instance.- 返回:
- An appropriately narrowed instance.
- 抛出:
HibernateException
-
proxyFor
public Object proxyFor(EntityPersister persister, EntityKey key, Object impl) throws HibernateException
从接口复制的说明:PersistenceContextReturn the existing proxy associated with the given EntityKey, or the third argument (the entity associated with the key) if no proxy exists. Init the proxy to the target implementation, if necessary.- 指定者:
proxyFor在接口中PersistenceContext- 抛出:
HibernateException
-
proxyFor
public Object proxyFor(Object impl) throws HibernateException
从接口复制的说明:PersistenceContextReturn the existing proxy associated with the given EntityKey, or the argument (the entity associated with the key) if no proxy exists. (slower than the form above)- 指定者:
proxyFor在接口中PersistenceContext- 抛出:
HibernateException
-
addEnhancedProxy
public void addEnhancedProxy(EntityKey key, PersistentAttributeInterceptable entity)
从接口复制的说明:PersistenceContextCross betweenPersistenceContext.addEntity(EntityKey, Object)andPersistenceContext.addProxy(EntityKey, Object)for use with enhancement-as-proxy- 指定者:
addEnhancedProxy在接口中PersistenceContext
-
getCollectionOwner
public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException
从接口复制的说明:PersistenceContextGet the entity that owns this persistent collection- 指定者:
getCollectionOwner在接口中PersistenceContext- 抛出:
MappingException
-
getLoadedCollectionOwnerOrNull
public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection)
从接口复制的说明:PersistenceContextGet the entity that owned this persistent collection when it was loaded- 指定者:
getLoadedCollectionOwnerOrNull在接口中PersistenceContext- 参数:
collection- The persistent collection- 返回:
- the owner if its entity ID is available from the collection's loaded key and the owner entity is in the persistence context; otherwise, returns null
-
getLoadedCollectionOwnerIdOrNull
public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection)
从接口复制的说明:PersistenceContextGet the ID for the entity that owned this persistent collection when it was loaded- 指定者:
getLoadedCollectionOwnerIdOrNull在接口中PersistenceContext- 参数:
collection- The persistent collection- 返回:
- the owner ID if available from the collection's loaded key; otherwise, returns null
-
addUninitializedCollection
public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
从接口复制的说明:PersistenceContextadd a collection we just loaded up (still needs initializing)- 指定者:
addUninitializedCollection在接口中PersistenceContext
-
addUninitializedDetachedCollection
public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection)
从接口复制的说明:PersistenceContextadd a detached uninitialized collection
-
addNewCollection
public void addNewCollection(CollectionPersister persister, PersistentCollection collection) throws HibernateException
从接口复制的说明:PersistenceContextAdd a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)- 指定者:
addNewCollection在接口中PersistenceContextcollection- The collection to be associated with the persistence context- 抛出:
HibernateException
-
addInitializedDetachedCollection
public void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection) throws HibernateException
从接口复制的说明:PersistenceContextadd an (initialized) collection that was created by another session and passed into update() (ie. one with a snapshot and existing state on the database)
-
addInitializedCollection
public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) throws HibernateException
从接口复制的说明:PersistenceContextadd a collection we just pulled out of the cache (does not need initializing)- 指定者:
addInitializedCollection在接口中PersistenceContext- 抛出:
HibernateException
-
getCollection
public PersistentCollection getCollection(CollectionKey collectionKey)
从接口复制的说明:PersistenceContextGet the collection instance associated with the CollectionKey- 指定者:
getCollection在接口中PersistenceContext
-
addNonLazyCollection
public void addNonLazyCollection(PersistentCollection collection)
从接口复制的说明:PersistenceContextRegister a collection for non-lazy loading at the end of the two-phase load- 指定者:
addNonLazyCollection在接口中PersistenceContext
-
initializeNonLazyCollections
public void initializeNonLazyCollections() throws HibernateException从接口复制的说明:PersistenceContextForce initialization of all non-lazy collections encountered during the current two-phase load (actually, this is a no-op, unless this is the "outermost" load)- 指定者:
initializeNonLazyCollections在接口中PersistenceContext- 抛出:
HibernateException
-
getCollectionHolder
public PersistentCollection getCollectionHolder(Object array)
从接口复制的说明:PersistenceContextGet the PersistentCollection object for an array- 指定者:
getCollectionHolder在接口中PersistenceContext
-
addCollectionHolder
public void addCollectionHolder(PersistentCollection holder)
从接口复制的说明:PersistenceContextRegister a PersistentCollection object for an array. Associates a holder with an array - MUST be called after loading array, since the array instance is not created until endLoad().- 指定者:
addCollectionHolder在接口中PersistenceContext
-
removeCollectionHolder
public PersistentCollection removeCollectionHolder(Object array)
从接口复制的说明:PersistenceContextRemove the mapping of collection to holder during eviction of the owning entity- 指定者:
removeCollectionHolder在接口中PersistenceContext
-
getSnapshot
public Serializable getSnapshot(PersistentCollection coll)
从接口复制的说明:PersistenceContextGet the snapshot of the pre-flush collection state- 指定者:
getSnapshot在接口中PersistenceContext
-
getCollectionEntryOrNull
public CollectionEntry getCollectionEntryOrNull(Object collection)
从接口复制的说明:PersistenceContextGet the collection entry for a collection passed to filter, which might be a collection wrapper, an array, or an unwrapped collection. Return null if there is no entry.- 指定者:
getCollectionEntryOrNull在接口中PersistenceContext
-
getProxy
public Object getProxy(EntityKey key)
从接口复制的说明:PersistenceContextGet an existing proxy by key- 指定者:
getProxy在接口中PersistenceContext
-
addProxy
public void addProxy(EntityKey key, Object proxy)
从接口复制的说明:PersistenceContextAdd a proxy to the session cache- 指定者:
addProxy在接口中PersistenceContext
-
removeProxy
public Object removeProxy(EntityKey key)
从接口复制的说明:PersistenceContextRemove a proxy from the session cache. Additionally, ensure that any load optimization references such as batch or subselect loading get cleaned up as well.- 指定者:
removeProxy在接口中PersistenceContext- 参数:
key- The key of the entity proxy to be removed- 返回:
- The proxy reference.
-
getNullifiableEntityKeys
public HashSet getNullifiableEntityKeys()
从接口复制的说明:PersistenceContextRetrieve the set of EntityKeys representing nullifiable references- 指定者:
getNullifiableEntityKeys在接口中PersistenceContext
-
getEntitiesByKey
@Deprecated public Map getEntitiesByKey()
已过时。this will be removed: it provides too wide access, making it hard to optimise the internals for specific access needs. Consider using #iterateEntities instead.从接口复制的说明:PersistenceContextGet the mapping from key value to entity instance- 指定者:
getEntitiesByKey在接口中PersistenceContext- 返回:
-
managedEntitiesIterator
public Iterator managedEntitiesIterator()
从接口复制的说明:PersistenceContextA read-only iterator on all entities managed by this persistence context- 指定者:
managedEntitiesIterator在接口中PersistenceContext
-
getNumberOfManagedEntities
public int getNumberOfManagedEntities()
- 指定者:
getNumberOfManagedEntities在接口中PersistenceContext
-
getEntityEntries
public Map getEntityEntries()
从接口复制的说明:PersistenceContextGet the mapping from entity instance to entity entry- 指定者:
getEntityEntries在接口中PersistenceContext
-
getCollectionEntries
@Deprecated public Map getCollectionEntries()
已过时。We should not expose this directly: the other accessors that have been created as a replacement have better chances of skipping initializing this map, which is a good performance improvement.从接口复制的说明:PersistenceContextGet the mapping from collection instance to collection entry- 指定者:
getCollectionEntries在接口中PersistenceContext- 返回:
- the map of managed collection entries.
-
forEachCollectionEntry
public void forEachCollectionEntry(BiConsumer<PersistentCollection,CollectionEntry> action, boolean concurrent)
从接口复制的说明:PersistenceContextExecute some action on each entry of the collectionEntries map, optionally iterating on a defensive copy.- 指定者:
forEachCollectionEntry在接口中PersistenceContext- 参数:
action- the lambda to apply on each PersistentCollection,CollectionEntry map entry of the PersistenceContext.concurrent- set this to false for improved efficiency, but that would make it illegal to make changes to the underlying collectionEntries map.
-
getCollectionsByKey
public Map getCollectionsByKey()
从接口复制的说明:PersistenceContextGet the mapping from collection key to collection instance- 指定者:
getCollectionsByKey在接口中PersistenceContext
-
getCascadeLevel
public int getCascadeLevel()
从接口复制的说明:PersistenceContextHow deep are we cascaded?- 指定者:
getCascadeLevel在接口中PersistenceContext
-
incrementCascadeLevel
public int incrementCascadeLevel()
从接口复制的说明:PersistenceContextCalled before cascading- 指定者:
incrementCascadeLevel在接口中PersistenceContext
-
decrementCascadeLevel
public int decrementCascadeLevel()
从接口复制的说明:PersistenceContextCalled after cascading- 指定者:
decrementCascadeLevel在接口中PersistenceContext
-
isFlushing
public boolean isFlushing()
从接口复制的说明:PersistenceContextIs a flush cycle currently in process?- 指定者:
isFlushing在接口中PersistenceContext
-
setFlushing
public void setFlushing(boolean flushing)
从接口复制的说明:PersistenceContextCalled before and after the flush cycle- 指定者:
setFlushing在接口中PersistenceContext
-
isRemovingOrphanBeforeUpates
public boolean isRemovingOrphanBeforeUpates()
-
beginRemoveOrphanBeforeUpdates
public void beginRemoveOrphanBeforeUpdates()
-
endRemoveOrphanBeforeUpdates
public void endRemoveOrphanBeforeUpdates()
-
beforeLoad
public void beforeLoad()
Call this before beginning a two-phase load- 指定者:
beforeLoad在接口中PersistenceContext
-
afterLoad
public void afterLoad()
Call this after finishing a two-phase load- 指定者:
afterLoad在接口中PersistenceContext
-
isLoadFinished
public boolean isLoadFinished()
从接口复制的说明:PersistenceContextIs in a two-phase load?- 指定者:
isLoadFinished在接口中PersistenceContext
-
toString
public String toString()
从接口复制的说明:PersistenceContextReturns a string representation of the object.- 指定者:
toString在接口中PersistenceContext- 覆盖:
toString在类中Object- 返回:
- a string representation of the object.
-
reentrantSafeEntityEntries
public Map.Entry<Object,EntityEntry>[] reentrantSafeEntityEntries()
从接口复制的说明:PersistenceContextProvides access to the entity/EntityEntry combos associated with the persistence context in a manner that is safe from reentrant access. Specifically, it is safe from additions/removals while iterating.- 指定者:
reentrantSafeEntityEntries在接口中PersistenceContext
-
getOwnerId
public Serializable getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap)
从接口复制的说明:PersistenceContextSearch this persistence context for an associated entity instance which is considered the "owner" of the given childEntity, and return that owner's id value. This is performed in the scenario of a uni-directional, non-inverse one-to-many collection (which means that the collection elements do not maintain a direct reference to the owner). As such, the processing here is basically to loop over every entity currently associated with this persistence context and for those of the correct entity (sub) type to extract its collection role property value and see if the child is contained within that collection. If so, we have found the owner; if not, we go on. Also need to account for mergeMap which acts as a local copy cache managed for the duration of a merge operation. It represents a map of the detached entity instances pointing to the corresponding managed instance.- 指定者:
getOwnerId在接口中PersistenceContext- 参数:
entityName- The entity name for the entity type which would own the childpropertyName- The name of the property on the owning entity type which would name this child association.childEntity- The child entity instance for which to locate the owner instance id.mergeMap- A map of non-persistent instances from an on-going merge operation (possibly null).- 返回:
- The id of the entityName instance which is said to own the child; null if an appropriate owner not located.
-
getIndexInOwner
public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap)
从接口复制的说明:PersistenceContextSearch the persistence context for an index of the child object, given a collection role- 指定者:
getIndexInOwner在接口中PersistenceContext
-
addNullProperty
public void addNullProperty(EntityKey ownerKey, String propertyName)
从接口复制的说明:PersistenceContextRecord the fact that the association belonging to the keyed entity is null.- 指定者:
addNullProperty在接口中PersistenceContext
-
isPropertyNull
public boolean isPropertyNull(EntityKey ownerKey, String propertyName)
从接口复制的说明:PersistenceContextIs the association property belonging to the keyed entity null?- 指定者:
isPropertyNull在接口中PersistenceContext
-
isReadOnly
public boolean isReadOnly(Object entityOrProxy)
从接口复制的说明:PersistenceContextIs the entity or proxy read-only? To determine the default read-only/modifiable setting used for entities and proxies that are loaded into the session useSession.isDefaultReadOnly()- 指定者:
isReadOnly在接口中PersistenceContext- 参数:
entityOrProxy- an entity or proxy- 返回:
trueif the object is read-only; otherwisefalseto indicate that the object is modifiable.
-
setReadOnly
public void setReadOnly(Object object, boolean readOnly)
从接口复制的说明:PersistenceContextSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing.- 指定者:
setReadOnly在接口中PersistenceContext- 参数:
object- an entity or proxyreadOnly- iftrue, the entity or proxy is made read-only; otherwise, the entity or proxy is made modifiable.- 另请参阅:
Session.setDefaultReadOnly(boolean),Session.setReadOnly(java.lang.Object, boolean),Query.setReadOnly(boolean)
-
replaceDelayedEntityIdentityInsertKeys
public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId)
-
serialize
public void serialize(ObjectOutputStream oos) throws IOException
Used by the owning session to explicitly control serialization of the persistence context.- 参数:
oos- The stream to which the persistence context should get written- 抛出:
IOException- serialization errors.
-
deserialize
public static StatefulPersistenceContext deserialize(ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException
Used by the owning session to explicitly control deserialization of the persistence context.- 参数:
ois- The stream from which the persistence context should be readsession- The owning session- 返回:
- The deserialized StatefulPersistenceContext
- 抛出:
IOException- deserialization errors.ClassNotFoundException- deserialization errors.
-
addChildParent
public void addChildParent(Object child, Object parent)
从接口复制的说明:PersistenceContextAdd a child/parent relation to cache for cascading op- 指定者:
addChildParent在接口中PersistenceContext- 参数:
child- The child of the relationshipparent- The parent of the relationship
-
removeChildParent
public void removeChildParent(Object child)
从接口复制的说明:PersistenceContextRemove child/parent relation from cache- 指定者:
removeChildParent在接口中PersistenceContext- 参数:
child- The child to be removed.
-
registerInsertedKey
public void registerInsertedKey(EntityPersister persister, Serializable id)
从接口复制的说明:PersistenceContextRegister keys inserted during the current transaction- 指定者:
registerInsertedKey在接口中PersistenceContext- 参数:
persister- The entity persisterid- The id
-
wasInsertedDuringTransaction
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id)
从接口复制的说明:PersistenceContextAllows callers to check to see if the identified entity was inserted during the current transaction.- 指定者:
wasInsertedDuringTransaction在接口中PersistenceContext- 参数:
persister- The entity persisterid- The id- 返回:
- True if inserted during this transaction, false otherwise.
-
containsNullifiableEntityKey
public boolean containsNullifiableEntityKey(Supplier<EntityKey> sek)
从接口复制的说明:PersistenceContextChecks if a certainEntityKeywas registered as nullifiable on thisPersistenceContext.- 指定者:
containsNullifiableEntityKey在接口中PersistenceContext- 参数:
sek- a supplier for the EntityKey; this allows to not always needing to create the key; for example if the map is known to be empty there is no need to create one to check.- 返回:
- true if the EntityKey had been registered before using
PersistenceContext.registerNullifiableEntityKey(EntityKey) - 另请参阅:
PersistenceContext.registerNullifiableEntityKey(EntityKey)
-
registerNullifiableEntityKey
public void registerNullifiableEntityKey(EntityKey key)
从接口复制的说明:PersistenceContextRegisters anEntityKeyas nullifiable on thisPersistenceContext.
-
isNullifiableEntityKeysEmpty
public boolean isNullifiableEntityKeysEmpty()
- 指定者:
isNullifiableEntityKeysEmpty在接口中PersistenceContext- 返回:
- true if no
EntityKeywas registered as nullifiable on thisPersistenceContext. - 另请参阅:
PersistenceContext.registerNullifiableEntityKey(EntityKey)
-
getCollectionEntriesSize
public int getCollectionEntriesSize()
从接口复制的说明:PersistenceContextThe size of the internal map storing all collection entries. (The map is not exposed directly, but the size is often useful)- 指定者:
getCollectionEntriesSize在接口中PersistenceContext- 返回:
- the size
-
removeCollectionEntry
public CollectionEntry removeCollectionEntry(PersistentCollection collection)
从接口复制的说明:PersistenceContextRemove aPersistentCollectionfrom thePersistenceContext.- 指定者:
removeCollectionEntry在接口中PersistenceContext- 参数:
collection- the collection to remove- 返回:
- the matching
CollectionEntry, if any was removed.
-
clearCollectionsByKey
public void clearCollectionsByKey()
从接口复制的说明:PersistenceContextRemove all state of the collections-by-key map.- 指定者:
clearCollectionsByKey在接口中PersistenceContext
-
addCollectionByKey
public PersistentCollection addCollectionByKey(CollectionKey collectionKey, PersistentCollection persistentCollection)
从接口复制的说明:PersistenceContextAdds a collection in the collections-by-key map.- 指定者:
addCollectionByKey在接口中PersistenceContext- 返回:
- the previous collection, it the key was already mapped.
-
removeCollectionByKey
public void removeCollectionByKey(CollectionKey collectionKey)
从接口复制的说明:PersistenceContextRemove a collection-by-key mapping.- 指定者:
removeCollectionByKey在接口中PersistenceContext- 参数:
collectionKey- the key to clear
-
getNaturalIdHelper
public PersistenceContext.NaturalIdHelper getNaturalIdHelper()
从接口复制的说明:PersistenceContextAccess to the natural-id helper for this persistence context- 指定者:
getNaturalIdHelper在接口中PersistenceContext- 返回:
- This persistence context's natural-id helper
-
-