Package org.hibernate.engine
Class StatefulPersistenceContext
java.lang.Object
org.hibernate.engine.StatefulPersistenceContext
- All Implemented Interfaces:
PersistenceContext
A PersistenceContext represents the state of persistent "stuff" which
Hibernate is tracking. This includes persistent entities, collections,
as well as proxies generated.
There is meant to be a one-to-one correspondence between a SessionImpl and
a PersistentContext. The SessionImpl uses the PersistentContext to track
the current state of its context. Event-listeners then use the
PersistentContext to drive their processing.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PersistentContext, bound to the given session. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildParent(Object child, Object parent) Put child/parent relation to cache for cascading opvoidRegister a PersistentCollection object for an array.addEntity(Object entity, Status status, Object[] loadedState, EntityKey entityKey, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched) Adds an entity to the internal caches.voidAdd a canonical mapping from entity key to entity instancevoidaddEntity(EntityUniqueKey euk, Object entity) Add an entity to the cache by unique keyaddEntry(Object entity, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched) Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.addInitializedCollection(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.voidaddNewCollection(CollectionPersister persister, PersistentCollection collection) Add a new collection (ie.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.voidAdd a proxy to the session cachevoidaddUninitializedCollection(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 loadedvoidCall this after finishing a two-phase loadvoidCalled after transactions endvoidCall this before begining a two-phase loadvoidcheckUniqueness(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 contextbooleancontainsCollection(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 contextbooleancontainsProxy(Object entity) Is the given proxy associated with this persistence context?intCalled after cascadingstatic StatefulPersistenceContextdeserialize(ObjectInputStream ois, SessionImplementor session) Get the BatchFetchQueue, instantiating one if necessary.Object[]Retrieve the cached database snapshot for the requested entity key.intDo we already know that the entity does not exist in the database?getCollection(CollectionKey collectionKey) Get the collection instance associated with the CollectionKeyGet the mapping from collection instance to collection entryGet the collection entry for a persistent collectiongetCollectionEntryOrNull(Object collection) Get the collection entry for a collection passed to filter, which might be a collection wrapper, an array, or an unwrapped collection.getCollectionHolder(Object array) Get the PersistentCollection object for an arraygetCollectionOwner(Serializable key, CollectionPersister collectionPersister) Get the entity that owns this persistent collectionGet 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 rowGet the mapping from key value to entity instanceGet the entity instance associated with the given EntityKeygetEntity(EntityUniqueKey euk) Get an entity cached by unique keyGet the mapping from entity instance to entity entryRetreive the EntityEntry representation of the given entity.getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) Search the persistence context for an index of the child object, given a collection roleRetrieve this persistence context's managed load context.getLoadedCollectionOwnerIdOrNull(PersistentCollection collection) Get the ID for the entity that owned this persistent collection when it was loadedgetLoadedCollectionOwnerOrNull(PersistentCollection collection) Get the entity that owned this persistent collection when it was loadedObject[]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.Retrieve the set of EntityKeys representing nullifiable referencesgetOwnerId(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.Get an existing proxy by keyGet the session to which this persistence context is bound.Get the snapshot of the pre-flush collection statebooleanintCalled before cascadingvoidForce 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)booleanWill 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:booleanisEntryFor(Object entity) Is there an EntityEntry for this instance?booleanIs a flush cycle currently in process?booleanIs in a two-phase load?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? To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session:booleannarrowProxy(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.Return the existing proxy associated with the given EntityKey, or the argument (the entity associated with the key) if no proxy exists.proxyFor(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.booleanTakes 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 proxyvoidregisterInsertedKey(EntityPersister persister, Serializable id) Register keys inserted during the current transactionvoidremoveChildParent(Object child) Remove child/parent relation from cacheremoveCollectionHolder(Object array) Remove the mapping of collection to holder during eviction of the owning entityremoveEntity(EntityKey key) Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntryremoveEntry(Object entity) Remove an entity entry from the session cacheremoveProxy(EntityKey key) Remove a proxy from the session cache.voidreplaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) voidUsed 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 flushcyclevoidsetReadOnly(Object object, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.toString()Returns a string representation of the object.Get the entity instance underlying the given proxy, throwing an exception if the proxy is uninitialized.unproxyAndReassociate(Object maybeProxy) Possibly unproxy the given reference and reassociate it with the current session.Get and remove a collection whose owner is not yet loaded, when its owner is being loadedbooleanwasInsertedDuringTransaction(EntityPersister persister, Serializable id) Allows callers to check to see if the identified entity was inserted during the current transaction.
-
Field Details
-
NO_ROW
-
-
Constructor Details
-
StatefulPersistenceContext
Constructs a PersistentContext, bound to the given session.- Parameters:
session- The session "owning" this context.
-
-
Method Details
-
isStateless
public boolean isStateless()- Specified by:
isStatelessin interfacePersistenceContext
-
getSession
Description copied from interface:PersistenceContextGet the session to which this persistence context is bound.- Specified by:
getSessionin interfacePersistenceContext- Returns:
- The session.
-
getLoadContexts
Description copied from interface:PersistenceContextRetrieve this persistence context's managed load context.- Specified by:
getLoadContextsin interfacePersistenceContext- Returns:
- The load context
-
addUnownedCollection
Description copied from interface:PersistenceContextAdd a collection which has no owner loaded- Specified by:
addUnownedCollectionin interfacePersistenceContext
-
useUnownedCollection
Description copied from interface:PersistenceContextGet and remove a collection whose owner is not yet loaded, when its owner is being loaded- Specified by:
useUnownedCollectionin interfacePersistenceContext
-
getBatchFetchQueue
Get the BatchFetchQueue, instantiating one if necessary.- Specified by:
getBatchFetchQueuein interfacePersistenceContext
-
clear
public void clear()Description copied from interface:PersistenceContextClear the state of the persistence context- Specified by:
clearin interfacePersistenceContext
-
isDefaultReadOnly
public boolean isDefaultReadOnly()Will 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:- Specified by:
isDefaultReadOnlyin interfacePersistenceContext- Returns:
- true, loaded entities/proxies will be made read-only by default; false, loaded entities/proxies will be made modifiable by default.
- See Also:
-
setDefaultReadOnly
public void setDefaultReadOnly(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. 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)- Specified by:
setDefaultReadOnlyin interfacePersistenceContext- Parameters:
defaultReadOnly- true, the default for loaded entities/proxies is read-only; false, the default for loaded entities/proxies is modifiable- See Also:
-
hasNonReadOnlyEntities
public boolean hasNonReadOnlyEntities()- Specified by:
hasNonReadOnlyEntitiesin interfacePersistenceContext- Returns:
- false if we know for certain that all the entities are read-only
-
setEntryStatus
Description copied from interface:PersistenceContextSet the status of an entry- Specified by:
setEntryStatusin interfacePersistenceContext
-
afterTransactionCompletion
public void afterTransactionCompletion()Description copied from interface:PersistenceContextCalled after transactions end- Specified by:
afterTransactionCompletionin interfacePersistenceContext
-
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- Specified by:
getDatabaseSnapshotin interfacePersistenceContext- Throws:
HibernateException
-
getNaturalIdSnapshot
public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister) throws HibernateException Description copied from interface: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.- Specified by:
getNaturalIdSnapshotin interfacePersistenceContext- Throws:
HibernateException
-
getCachedDatabaseSnapshot
Retrieve the cached database snapshot for the requested entity key. This differs fromgetDatabaseSnapshot(java.io.Serializable, org.hibernate.persister.entity.EntityPersister)is two important respects:- no snapshot is obtained from the database if not already cached
- an entry of
NO_ROWhere is interpretet as an exception
- Specified by:
getCachedDatabaseSnapshotin interfacePersistenceContext- Parameters:
key- The entity key for which to retrieve the cached snapshot- Returns:
- The cached snapshot
- Throws:
IllegalStateException- if the cached snapshot was ==NO_ROW.
-
addEntity
Description copied from interface:PersistenceContextAdd a canonical mapping from entity key to entity instance- Specified by:
addEntityin interfacePersistenceContext
-
getEntity
Get the entity instance associated with the given EntityKey- Specified by:
getEntityin interfacePersistenceContext
-
containsEntity
Description copied from interface:PersistenceContextIs there an entity with the given key in the persistence context- Specified by:
containsEntityin interfacePersistenceContext
-
removeEntity
Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntry- Specified by:
removeEntityin interfacePersistenceContext
-
getEntity
Get an entity cached by unique key- Specified by:
getEntityin interfacePersistenceContext
-
addEntity
Add an entity to the cache by unique key- Specified by:
addEntityin interfacePersistenceContext
-
getEntry
Retreive the EntityEntry representation of the given entity.- Specified by:
getEntryin interfacePersistenceContext- Parameters:
entity- The entity for which to locate the EntityEntry.- Returns:
- The EntityEntry for the given entity.
-
removeEntry
Remove an entity entry from the session cache- Specified by:
removeEntryin interfacePersistenceContext
-
isEntryFor
Is there an EntityEntry for this instance?- Specified by:
isEntryForin interfacePersistenceContext
-
getCollectionEntry
Get the collection entry for a persistent collection- Specified by:
getCollectionEntryin interfacePersistenceContext
-
addEntity
public EntityEntry addEntity(Object entity, Status status, Object[] loadedState, EntityKey entityKey, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched) Adds an entity to the internal caches.- Specified by:
addEntityin interfacePersistenceContext
-
addEntry
public EntityEntry addEntry(Object entity, Status status, Object[] loadedState, Object rowId, Serializable id, Object version, LockMode lockMode, boolean existsInDatabase, EntityPersister persister, boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched) Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.- Specified by:
addEntryin interfacePersistenceContext
-
containsCollection
Description copied from interface:PersistenceContextIs the given collection associated with this persistence context?- Specified by:
containsCollectionin interfacePersistenceContext
-
containsProxy
Description copied from interface:PersistenceContextIs the given proxy associated with this persistence context?- Specified by:
containsProxyin interfacePersistenceContext
-
reassociateIfUninitializedProxy
Takes the given object and, if it represents a proxy, reassociates it with this event source.- Specified by:
reassociateIfUninitializedProxyin interfacePersistenceContext- Parameters:
value- The possible proxy to be reassociated.- Returns:
- Whether the passed value represented an actual proxy which got initialized.
- Throws:
MappingException
-
reassociateProxy
If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy- Specified by:
reassociateProxyin interfacePersistenceContext- Throws:
MappingException
-
unproxy
Get 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.- Specified by:
unproxyin interfacePersistenceContext- Throws:
HibernateException
-
unproxyAndReassociate
Possibly unproxy the given reference and reassociate it with the current session.- Specified by:
unproxyAndReassociatein interfacePersistenceContext- Parameters:
maybeProxy- The reference to be unproxied if it currently represents a proxy.- Returns:
- The unproxied instance.
- Throws:
HibernateException
-
checkUniqueness
Attempts to check whether the given key represents an entity already loaded within the current session.- Specified by:
checkUniquenessin interfacePersistenceContext- Parameters:
object- The entity reference against which to perform the uniqueness check.- Throws:
HibernateException
-
narrowProxy
public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object) throws HibernateException If 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.- Specified by:
narrowProxyin interfacePersistenceContext- Parameters:
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.- Returns:
- An appropriately narrowed instance.
- Throws:
HibernateException
-
proxyFor
public Object proxyFor(EntityPersister persister, EntityKey key, Object impl) throws HibernateException Return 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.- Specified by:
proxyForin interfacePersistenceContext- Throws:
HibernateException
-
proxyFor
Return 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)- Specified by:
proxyForin interfacePersistenceContext- Throws:
HibernateException
-
getCollectionOwner
public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException Get the entity that owns this persistent collection- Specified by:
getCollectionOwnerin interfacePersistenceContext- Throws:
MappingException
-
getLoadedCollectionOwnerOrNull
Get the entity that owned this persistent collection when it was loaded- Specified by:
getLoadedCollectionOwnerOrNullin interfacePersistenceContext- Parameters:
collection- The persistent collection- Returns:
- 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
Get the ID for the entity that owned this persistent collection when it was loaded- Specified by:
getLoadedCollectionOwnerIdOrNullin interfacePersistenceContext- Parameters:
collection- The persistent collection- Returns:
- the owner ID if available from the collection's loaded key; otherwise, returns null
-
addUninitializedCollection
public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) add a collection we just loaded up (still needs initializing)- Specified by:
addUninitializedCollectionin interfacePersistenceContext
-
addUninitializedDetachedCollection
public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection) add a detached uninitialized collection- Specified by:
addUninitializedDetachedCollectionin interfacePersistenceContext
-
addNewCollection
public void addNewCollection(CollectionPersister persister, PersistentCollection collection) throws HibernateException Add a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)- Specified by:
addNewCollectionin interfacePersistenceContext- Parameters:
collection- The collection to be associated with the persistence context- Throws:
HibernateException
-
addInitializedDetachedCollection
public void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection) throws HibernateException 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)- Specified by:
addInitializedDetachedCollectionin interfacePersistenceContext- Throws:
HibernateException
-
addInitializedCollection
public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) throws HibernateException add a collection we just pulled out of the cache (does not need initializing)- Specified by:
addInitializedCollectionin interfacePersistenceContext- Throws:
HibernateException
-
getCollection
Get the collection instance associated with the CollectionKey- Specified by:
getCollectionin interfacePersistenceContext
-
addNonLazyCollection
Register a collection for non-lazy loading at the end of the two-phase load- Specified by:
addNonLazyCollectionin interfacePersistenceContext
-
initializeNonLazyCollections
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)- Specified by:
initializeNonLazyCollectionsin interfacePersistenceContext- Throws:
HibernateException
-
getCollectionHolder
Get the PersistentCollection object for an array- Specified by:
getCollectionHolderin interfacePersistenceContext
-
addCollectionHolder
Register 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().- Specified by:
addCollectionHolderin interfacePersistenceContext
-
removeCollectionHolder
Description copied from interface:PersistenceContextRemove the mapping of collection to holder during eviction of the owning entity- Specified by:
removeCollectionHolderin interfacePersistenceContext
-
getSnapshot
Get the snapshot of the pre-flush collection state- Specified by:
getSnapshotin interfacePersistenceContext
-
getCollectionEntryOrNull
Get 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.- Specified by:
getCollectionEntryOrNullin interfacePersistenceContext
-
getProxy
Get an existing proxy by key- Specified by:
getProxyin interfacePersistenceContext
-
addProxy
Add a proxy to the session cache- Specified by:
addProxyin interfacePersistenceContext
-
removeProxy
Remove a proxy from the session cache. Additionally, ensure that any load optimization references such as batch or subselect loading get cleaned up as well.- Specified by:
removeProxyin interfacePersistenceContext- Parameters:
key- The key of the entity proxy to be removed- Returns:
- The proxy reference.
-
getNullifiableEntityKeys
Retrieve the set of EntityKeys representing nullifiable references- Specified by:
getNullifiableEntityKeysin interfacePersistenceContext
-
getEntitiesByKey
Description copied from interface:PersistenceContextGet the mapping from key value to entity instance- Specified by:
getEntitiesByKeyin interfacePersistenceContext
-
getProxiesByKey
-
getEntityEntries
Description copied from interface:PersistenceContextGet the mapping from entity instance to entity entry- Specified by:
getEntityEntriesin interfacePersistenceContext
-
getCollectionEntries
Description copied from interface:PersistenceContextGet the mapping from collection instance to collection entry- Specified by:
getCollectionEntriesin interfacePersistenceContext
-
getCollectionsByKey
Description copied from interface:PersistenceContextGet the mapping from collection key to collection instance- Specified by:
getCollectionsByKeyin interfacePersistenceContext
-
getCascadeLevel
public int getCascadeLevel()Do we already know that the entity does not exist in the database?- Specified by:
getCascadeLevelin interfacePersistenceContext
-
incrementCascadeLevel
public int incrementCascadeLevel()Description copied from interface:PersistenceContextCalled before cascading- Specified by:
incrementCascadeLevelin interfacePersistenceContext
-
decrementCascadeLevel
public int decrementCascadeLevel()Description copied from interface:PersistenceContextCalled after cascading- Specified by:
decrementCascadeLevelin interfacePersistenceContext
-
isFlushing
public boolean isFlushing()Description copied from interface:PersistenceContextIs a flush cycle currently in process?- Specified by:
isFlushingin interfacePersistenceContext
-
setFlushing
public void setFlushing(boolean flushing) Description copied from interface:PersistenceContextCalled before and after the flushcycle- Specified by:
setFlushingin interfacePersistenceContext
-
beforeLoad
public void beforeLoad()Call this before begining a two-phase load- Specified by:
beforeLoadin interfacePersistenceContext
-
afterLoad
public void afterLoad()Call this after finishing a two-phase load- Specified by:
afterLoadin interfacePersistenceContext
-
isLoadFinished
public boolean isLoadFinished()Description copied from interface:PersistenceContextIs in a two-phase load?- Specified by:
isLoadFinishedin interfacePersistenceContext
-
toString
Returns a string representation of the object.- Specified by:
toStringin interfacePersistenceContext- Overrides:
toStringin classObject- Returns:
- a string representation of the object.
-
getOwnerId
public Serializable getOwnerId(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. 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.- Specified by:
getOwnerIdin interfacePersistenceContext- Parameters:
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).- Returns:
- The id of the entityName instance which is said to own the child; null if an appropriate owner not located.
-
getIndexInOwner
Search the persistence context for an index of the child object, given a collection role- Specified by:
getIndexInOwnerin interfacePersistenceContext
-
addNullProperty
Record the fact that the association belonging to the keyed entity is null.- Specified by:
addNullPropertyin interfacePersistenceContext
-
isPropertyNull
Is the association property belonging to the keyed entity null?- Specified by:
isPropertyNullin interfacePersistenceContext
-
isReadOnly
Description copied from interface:PersistenceContextIs the entity or proxy read-only? To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session:- Specified by:
isReadOnlyin interfacePersistenceContext- Parameters:
entityOrProxy-- Returns:
- true, the object is read-only; false, the object is modifiable.
- See Also:
-
setReadOnly
Description copied from interface: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. To set the default read-only/modifiable setting used for entities and proxies that are loaded into this persistence context:- Specified by:
setReadOnlyin interfacePersistenceContext- Parameters:
object- , an entity or HibernateProxyreadOnly- if true, the entity or proxy is made read-only; if false, the entity or proxy is made modifiable.- See Also:
-
replaceDelayedEntityIdentityInsertKeys
- Specified by:
replaceDelayedEntityIdentityInsertKeysin interfacePersistenceContext
-
serialize
Used by the owning session to explicitly control serialization of the persistence context.- Parameters:
oos- The stream to which the persistence context should get written- Throws:
IOException- serialization errors.
-
deserialize
public static StatefulPersistenceContext deserialize(ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException - Throws:
IOExceptionClassNotFoundException
-
addChildParent
Description copied from interface:PersistenceContextPut child/parent relation to cache for cascading op- Specified by:
addChildParentin interfacePersistenceContext- Parameters:
child-parent-- See Also:
-
removeChildParent
Description copied from interface:PersistenceContextRemove child/parent relation from cache- Specified by:
removeChildParentin interfacePersistenceContext- Parameters:
child-- See Also:
-
registerInsertedKey
Register keys inserted during the current transaction- Specified by:
registerInsertedKeyin interfacePersistenceContext- Parameters:
persister- The entity persisterid- The id
-
wasInsertedDuringTransaction
Allows callers to check to see if the identified entity was inserted during the current transaction.- Specified by:
wasInsertedDuringTransactionin interfacePersistenceContext- Parameters:
persister- The entity persisterid- The id- Returns:
- True if inserted during this transaction, false otherwise.
-