C# Class NHibernate.Engine.StatefulPersistenceContext

Inheritance: IPersistenceContext, ISerializable, IDeserializationCallback
Datei anzeigen Open project: nhibernate/nhibernate-core

Public Properties

Property Type Description
NoRow object

Public Methods

Method Description
AddChildParent ( object child, object parent ) : void
AddCollectionHolder ( IPersistentCollection holder ) : void

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().

AddEntity ( object entity, Status status, object loadedState, NHibernate.Engine.EntityKey entityKey, object version, LockMode lockMode, bool existsInDatabase, IEntityPersister persister, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched ) : EntityEntry

Adds an entity to the internal caches.

AddEntity ( NHibernate.Engine.EntityKey key, object entity ) : void

Add a canonical mapping from entity key to entity instance

AddEntity ( NHibernate.Engine.EntityUniqueKey euk, object entity ) : void

Add an entity to the cache by unique key

AddEntry ( object entity, Status status, object loadedState, object rowId, object id, object version, LockMode lockMode, bool existsInDatabase, IEntityPersister persister, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched ) : EntityEntry

Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.

AddInitializedCollection ( ICollectionPersister persister, IPersistentCollection collection, object id ) : CollectionEntry

add a collection we just pulled out of the cache (does not need initializing)

AddInitializedDetachedCollection ( ICollectionPersister collectionPersister, IPersistentCollection collection ) : void

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)

AddNewCollection ( ICollectionPersister persister, IPersistentCollection collection ) : void

Add a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)

AddNonLazyCollection ( IPersistentCollection collection ) : void

Register a collection for non-lazy loading at the end of the two-phase load

AddNullProperty ( NHibernate.Engine.EntityKey ownerKey, string propertyName ) : void

Record the fact that the association belonging to the keyed entity is null.

AddProxy ( NHibernate.Engine.EntityKey key, INHibernateProxy proxy ) : void

Add a proxy to the session cache

AddUninitializedCollection ( ICollectionPersister persister, IPersistentCollection collection, object id ) : void

add a collection we just loaded up (still needs initializing)

AddUninitializedDetachedCollection ( ICollectionPersister persister, IPersistentCollection collection ) : void

add a detached uninitialized collection

AddUnownedCollection ( CollectionKey key, IPersistentCollection collection ) : void

Add a collection which has no owner loaded

AfterLoad ( ) : void

Call this after finishing a two-phase load

AfterTransactionCompletion ( ) : void

Called after transactions end

BeforeLoad ( ) : void

Call this before begining a two-phase load

CheckUniqueness ( EntityKey key, object obj ) : void

Attempts to check whether the given key represents an entity already loaded within the current session.

Clear ( ) : void

Clear the state of the persistence context

ContainsCollection ( IPersistentCollection collection ) : bool

Is the given collection associated with this persistence context?

ContainsEntity ( EntityKey key ) : bool

Is there an entity with the given key in the persistence context

ContainsProxy ( INHibernateProxy proxy ) : bool

Is the given proxy associated with this persistence context?

DecrementCascadeLevel ( ) : int

Called after cascading

GetCachedDatabaseSnapshot ( EntityKey key ) : object[]

Retrieve the cached database snapshot for the requested entity key.

This differs from GetDatabaseSnapshot is two important respects: no snapshot is obtained from the database if not already cached an entry of NO_ROW here is interpreted as an exception

GetCollection ( CollectionKey collectionKey ) : IPersistentCollection

Get the collection instance associated with the CollectionKey

GetCollectionEntry ( IPersistentCollection coll ) : CollectionEntry

Get the collection entry for a persistent collection

GetCollectionEntryOrNull ( object collection ) : CollectionEntry

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.

GetCollectionHolder ( object array ) : IPersistentCollection

Get the PersistentCollection object for an array

GetCollectionOwner ( object key, ICollectionPersister collectionPersister ) : object

Get the entity that owns this persistent collection

GetDatabaseSnapshot ( object id, IEntityPersister persister ) : object[]

Get the current state of the entity as known to the underlying database, or null if there is no corresponding row

GetEntity ( EntityKey key ) : object

Get the entity instance associated with the given EntityKey

GetEntity ( EntityUniqueKey euk ) : object

Get an entity cached by unique key

GetEntry ( object entity ) : EntityEntry

Retrieve the EntityEntry representation of the given entity.

GetIndexInOwner ( string entity, string property, object childEntity, IDictionary mergeMap ) : object

Search the persistence context for an index of the child object, given a collection role

GetLoadedCollectionOwnerIdOrNull ( IPersistentCollection collection ) : object

Get the ID for the entity that owned this persistent collection when it was loaded

GetLoadedCollectionOwnerOrNull ( IPersistentCollection collection ) : object

Get the entity that owned this persistent collection when it was loaded

GetNaturalIdSnapshot ( object id, IEntityPersister persister ) : object[]

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.

GetOwnerId ( string entityName, string propertyName, object childEntity, IDictionary mergeMap ) : object

Search the persistence context for an owner for the child object, given a collection role

GetProxy ( EntityKey key ) : object

Get an existing proxy by key

GetSnapshot ( IPersistentCollection coll ) : object

Get the snapshot of the pre-flush collection state

IncrementCascadeLevel ( ) : int

Called before cascading

InitializeNonLazyCollections ( ) : void

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)

IsEntryFor ( object entity ) : bool

Is there an EntityEntry for this instance?

IsPropertyNull ( EntityKey ownerKey, string propertyName ) : bool

Is the association property belonging to the keyed entity null?

IsReadOnly ( object entityOrProxy ) : bool
NarrowProxy ( INHibernateProxy proxy, IEntityPersister persister, EntityKey key, object obj ) : object

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.

ProxyFor ( IEntityPersister persister, EntityKey key, object impl ) : object

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.

ProxyFor ( object impl ) : object

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)

ReassociateIfUninitializedProxy ( object value ) : bool

Takes the given object and, if it represents a proxy, reassociates it with this event source.

ReassociateProxy ( object value, object id ) : void

If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy

RemoveChildParent ( object child ) : void
RemoveCollectionHolder ( object array ) : IPersistentCollection

Remove the mapping of collection to holder during eviction of the owning entity

RemoveEntity ( EntityKey key ) : object

Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntry

RemoveEntry ( object entity ) : EntityEntry

Remove an entity entry from the session cache

RemoveProxy ( EntityKey key ) : object

Remove a proxy from the session cache

ReplaceDelayedEntityIdentityInsertKeys ( EntityKey oldKey, object generatedId ) : void
SetEntryStatus ( EntityEntry entry, Status status ) : void

Set the status of an entry

SetReadOnly ( object entityOrProxy, bool readOnly ) : void
StatefulPersistenceContext ( ISessionImplementor session ) : System

Constructs a PersistentContext, bound to the given session.

ToString ( ) : string
Unproxy ( object maybeProxy ) : object

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.

UnproxyAndReassociate ( object maybeProxy ) : object

Possibly unproxy the given reference and reassociate it with the current session.

UseUnownedCollection ( CollectionKey key ) : IPersistentCollection

Get and remove a collection whose owner is not yet loaded, when its owner is being loaded

Private Methods

Method Description
AddCollection ( IPersistentCollection coll, CollectionEntry entry, object key ) : void

Add an collection to the cache, with a given collection entry.

AddCollection ( IPersistentCollection collection, ICollectionPersister persister ) : void

Add a collection to the cache, creating a new collection entry for it

ClearNullProperties ( ) : void
GetIndexInParent ( string property, object childEntity, IEntityPersister persister, ICollectionPersister collectionPersister, object potentialParent ) : object
GetLoadedCollectionOwnerIdOrNull ( CollectionEntry ce ) : object

Get the ID for the entity that owned this persistent collection when it was loaded

IDeserializationCallback ( object sender ) : void
ISerializable ( SerializationInfo info, StreamingContext context ) : void
InitTransientState ( ) : void
IsFoundInParent ( string property, object childEntity, IEntityPersister persister, ICollectionPersister collectionPersister, object potentialParent ) : bool
ReassociateProxy ( ILazyInitializer li, INHibernateProxy proxy ) : void

Associate a proxy that was instantiated by another session with this session

SetEntityReadOnly ( object entity, bool readOnly ) : void
SetHasNonReadOnlyEnties ( Status value ) : void
SetProxyReadOnly ( INHibernateProxy proxy, bool readOnly ) : void
SetSession ( ISessionImplementor session ) : void
StatefulPersistenceContext ( SerializationInfo info, StreamingContext context ) : System

Method Details

AddChildParent() public method

public AddChildParent ( object child, object parent ) : void
child object
parent object
return void

AddCollectionHolder() public method

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().
public AddCollectionHolder ( IPersistentCollection holder ) : void
holder IPersistentCollection
return void

AddEntity() public method

Adds an entity to the internal caches.
public AddEntity ( object entity, Status status, object loadedState, NHibernate.Engine.EntityKey entityKey, object version, LockMode lockMode, bool existsInDatabase, IEntityPersister persister, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched ) : EntityEntry
entity object
status Status
loadedState object
entityKey NHibernate.Engine.EntityKey
version object
lockMode LockMode
existsInDatabase bool
persister IEntityPersister
disableVersionIncrement bool
lazyPropertiesAreUnfetched bool
return EntityEntry

AddEntity() public method

Add a canonical mapping from entity key to entity instance
public AddEntity ( NHibernate.Engine.EntityKey key, object entity ) : void
key NHibernate.Engine.EntityKey
entity object
return void

AddEntity() public method

Add an entity to the cache by unique key
public AddEntity ( NHibernate.Engine.EntityUniqueKey euk, object entity ) : void
euk NHibernate.Engine.EntityUniqueKey
entity object
return void

AddEntry() public method

Generates an appropriate EntityEntry instance and adds it to the event source's internal caches.
public AddEntry ( object entity, Status status, object loadedState, object rowId, object id, object version, LockMode lockMode, bool existsInDatabase, IEntityPersister persister, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched ) : EntityEntry
entity object
status Status
loadedState object
rowId object
id object
version object
lockMode LockMode
existsInDatabase bool
persister IEntityPersister
disableVersionIncrement bool
lazyPropertiesAreUnfetched bool
return EntityEntry

AddInitializedCollection() public method

add a collection we just pulled out of the cache (does not need initializing)
public AddInitializedCollection ( ICollectionPersister persister, IPersistentCollection collection, object id ) : CollectionEntry
persister ICollectionPersister
collection IPersistentCollection
id object
return CollectionEntry

AddInitializedDetachedCollection() public method

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)
public AddInitializedDetachedCollection ( ICollectionPersister collectionPersister, IPersistentCollection collection ) : void
collectionPersister ICollectionPersister
collection IPersistentCollection
return void

AddNewCollection() public method

Add a new collection (ie. a newly created one, just instantiated by the application, with no database state or snapshot)
public AddNewCollection ( ICollectionPersister persister, IPersistentCollection collection ) : void
persister ICollectionPersister
collection IPersistentCollection The collection to be associated with the persistence context
return void

AddNonLazyCollection() public method

Register a collection for non-lazy loading at the end of the two-phase load
public AddNonLazyCollection ( IPersistentCollection collection ) : void
collection IPersistentCollection
return void

AddNullProperty() public method

Record the fact that the association belonging to the keyed entity is null.
public AddNullProperty ( NHibernate.Engine.EntityKey ownerKey, string propertyName ) : void
ownerKey NHibernate.Engine.EntityKey
propertyName string
return void

AddProxy() public method

Add a proxy to the session cache
public AddProxy ( NHibernate.Engine.EntityKey key, INHibernateProxy proxy ) : void
key NHibernate.Engine.EntityKey
proxy INHibernateProxy
return void

AddUninitializedCollection() public method

add a collection we just loaded up (still needs initializing)
public AddUninitializedCollection ( ICollectionPersister persister, IPersistentCollection collection, object id ) : void
persister ICollectionPersister
collection IPersistentCollection
id object
return void

AddUninitializedDetachedCollection() public method

add a detached uninitialized collection
public AddUninitializedDetachedCollection ( ICollectionPersister persister, IPersistentCollection collection ) : void
persister ICollectionPersister
collection IPersistentCollection
return void

AddUnownedCollection() public method

Add a collection which has no owner loaded
public AddUnownedCollection ( CollectionKey key, IPersistentCollection collection ) : void
key CollectionKey
collection IPersistentCollection
return void

AfterLoad() public method

Call this after finishing a two-phase load
public AfterLoad ( ) : void
return void

AfterTransactionCompletion() public method

Called after transactions end
public AfterTransactionCompletion ( ) : void
return void

BeforeLoad() public method

Call this before begining a two-phase load
public BeforeLoad ( ) : void
return void

CheckUniqueness() public method

Attempts to check whether the given key represents an entity already loaded within the current session.
public CheckUniqueness ( EntityKey key, object obj ) : void
key EntityKey The entity key.
obj object The entity reference against which to perform the uniqueness check.
return void

Clear() public method

Clear the state of the persistence context
public Clear ( ) : void
return void

ContainsCollection() public method

Is the given collection associated with this persistence context?
public ContainsCollection ( IPersistentCollection collection ) : bool
collection IPersistentCollection
return bool

ContainsEntity() public method

Is there an entity with the given key in the persistence context
public ContainsEntity ( EntityKey key ) : bool
key EntityKey
return bool

ContainsProxy() public method

Is the given proxy associated with this persistence context?
public ContainsProxy ( INHibernateProxy proxy ) : bool
proxy INHibernateProxy
return bool

DecrementCascadeLevel() public method

Called after cascading
public DecrementCascadeLevel ( ) : int
return int

GetCachedDatabaseSnapshot() public method

Retrieve the cached database snapshot for the requested entity key.
This differs from GetDatabaseSnapshot is two important respects: no snapshot is obtained from the database if not already cached an entry of NO_ROW here is interpreted as an exception
public GetCachedDatabaseSnapshot ( EntityKey key ) : object[]
key EntityKey The entity key for which to retrieve the cached snapshot
return object[]

GetCollection() public method

Get the collection instance associated with the CollectionKey
public GetCollection ( CollectionKey collectionKey ) : IPersistentCollection
collectionKey CollectionKey
return IPersistentCollection

GetCollectionEntry() public method

Get the collection entry for a persistent collection
public GetCollectionEntry ( IPersistentCollection coll ) : CollectionEntry
coll IPersistentCollection
return CollectionEntry

GetCollectionEntryOrNull() public method

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.
public GetCollectionEntryOrNull ( object collection ) : CollectionEntry
collection object
return CollectionEntry

GetCollectionHolder() public method

Get the PersistentCollection object for an array
public GetCollectionHolder ( object array ) : IPersistentCollection
array object
return IPersistentCollection

GetCollectionOwner() public method

Get the entity that owns this persistent collection
public GetCollectionOwner ( object key, ICollectionPersister collectionPersister ) : object
key object
collectionPersister ICollectionPersister
return object

GetDatabaseSnapshot() public method

Get the current state of the entity as known to the underlying database, or null if there is no corresponding row
public GetDatabaseSnapshot ( object id, IEntityPersister persister ) : object[]
id object
persister IEntityPersister
return object[]

GetEntity() public method

Get the entity instance associated with the given EntityKey
public GetEntity ( EntityKey key ) : object
key EntityKey
return object

GetEntity() public method

Get an entity cached by unique key
public GetEntity ( EntityUniqueKey euk ) : object
euk EntityUniqueKey
return object

GetEntry() public method

Retrieve the EntityEntry representation of the given entity.
public GetEntry ( object entity ) : EntityEntry
entity object The entity for which to locate the EntityEntry.
return EntityEntry

GetIndexInOwner() public method

Search the persistence context for an index of the child object, given a collection role
public GetIndexInOwner ( string entity, string property, object childEntity, IDictionary mergeMap ) : object
entity string
property string
childEntity object
mergeMap IDictionary
return object

GetLoadedCollectionOwnerIdOrNull() public method

Get the ID for the entity that owned this persistent collection when it was loaded
public GetLoadedCollectionOwnerIdOrNull ( IPersistentCollection collection ) : object
collection IPersistentCollection The persistent collection
return object

GetLoadedCollectionOwnerOrNull() public method

Get the entity that owned this persistent collection when it was loaded
public GetLoadedCollectionOwnerOrNull ( IPersistentCollection collection ) : object
collection IPersistentCollection The persistent collection
return object

GetNaturalIdSnapshot() public method

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.
public GetNaturalIdSnapshot ( object id, IEntityPersister persister ) : object[]
id object
persister IEntityPersister
return object[]

GetOwnerId() public method

Search the persistence context for an owner for the child object, given a collection role
public GetOwnerId ( string entityName, string propertyName, object childEntity, IDictionary mergeMap ) : object
entityName string
propertyName string
childEntity object
mergeMap IDictionary
return object

GetProxy() public method

Get an existing proxy by key
public GetProxy ( EntityKey key ) : object
key EntityKey
return object

GetSnapshot() public method

Get the snapshot of the pre-flush collection state
public GetSnapshot ( IPersistentCollection coll ) : object
coll IPersistentCollection
return object

IncrementCascadeLevel() public method

Called before cascading
public IncrementCascadeLevel ( ) : int
return int

InitializeNonLazyCollections() public method

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)
public InitializeNonLazyCollections ( ) : void
return void

IsEntryFor() public method

Is there an EntityEntry for this instance?
public IsEntryFor ( object entity ) : bool
entity object
return bool

IsPropertyNull() public method

Is the association property belonging to the keyed entity null?
public IsPropertyNull ( EntityKey ownerKey, string propertyName ) : bool
ownerKey EntityKey
propertyName string
return bool

IsReadOnly() public method

public IsReadOnly ( object entityOrProxy ) : bool
entityOrProxy object
return bool

NarrowProxy() public method

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.
public NarrowProxy ( INHibernateProxy proxy, IEntityPersister persister, EntityKey key, object obj ) : object
proxy INHibernateProxy The proxy instance to be narrowed.
persister IEntityPersister The persister for the proxied entity.
key EntityKey The internal cache key for the proxied entity.
obj object (optional) the actual proxied entity instance.
return object

ProxyFor() public method

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.
public ProxyFor ( IEntityPersister persister, EntityKey key, object impl ) : object
persister IEntityPersister
key EntityKey
impl object
return object

ProxyFor() public method

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)
public ProxyFor ( object impl ) : object
impl object
return object

ReassociateIfUninitializedProxy() public method

Takes the given object and, if it represents a proxy, reassociates it with this event source.
public ReassociateIfUninitializedProxy ( object value ) : bool
value object The possible proxy to be reassociated.
return bool

ReassociateProxy() public method

If a deleted entity instance is re-saved, and it has a proxy, we need to reset the identifier of the proxy
public ReassociateProxy ( object value, object id ) : void
value object
id object
return void

RemoveChildParent() public method

public RemoveChildParent ( object child ) : void
child object
return void

RemoveCollectionHolder() public method

Remove the mapping of collection to holder during eviction of the owning entity
public RemoveCollectionHolder ( object array ) : IPersistentCollection
array object
return IPersistentCollection

RemoveEntity() public method

Remove an entity from the session cache, also clear up other state associated with the entity, all except for the EntityEntry
public RemoveEntity ( EntityKey key ) : object
key EntityKey
return object

RemoveEntry() public method

Remove an entity entry from the session cache
public RemoveEntry ( object entity ) : EntityEntry
entity object
return EntityEntry

RemoveProxy() public method

Remove a proxy from the session cache
public RemoveProxy ( EntityKey key ) : object
key EntityKey
return object

ReplaceDelayedEntityIdentityInsertKeys() public method

public ReplaceDelayedEntityIdentityInsertKeys ( EntityKey oldKey, object generatedId ) : void
oldKey EntityKey
generatedId object
return void

SetEntryStatus() public method

Set the status of an entry
public SetEntryStatus ( EntityEntry entry, Status status ) : void
entry EntityEntry
status Status
return void

SetReadOnly() public method

public SetReadOnly ( object entityOrProxy, bool readOnly ) : void
entityOrProxy object
readOnly bool
return void

StatefulPersistenceContext() public method

Constructs a PersistentContext, bound to the given session.
public StatefulPersistenceContext ( ISessionImplementor session ) : System
session ISessionImplementor The session "owning" this context.
return System

ToString() public method

public ToString ( ) : string
return string

Unproxy() public method

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.
public Unproxy ( object maybeProxy ) : object
maybeProxy object
return object

UnproxyAndReassociate() public method

Possibly unproxy the given reference and reassociate it with the current session.
public UnproxyAndReassociate ( object maybeProxy ) : object
maybeProxy object The reference to be unproxied if it currently represents a proxy.
return object

UseUnownedCollection() public method

Get and remove a collection whose owner is not yet loaded, when its owner is being loaded
public UseUnownedCollection ( CollectionKey key ) : IPersistentCollection
key CollectionKey
return IPersistentCollection

Property Details

NoRow public_oe static_oe property

public static object NoRow
return object