C# Class Castle.ActiveRecord.HookDispatcher

Translates the IInterceptor messages to instance possible hooks
Inheritance: NHibernate.EmptyInterceptor
Show file Open project: shosca/ActiveRecord

Public Methods

Method Description
FindDirty ( object entity, object id, object currentState, object previousState, string propertyNames, IType types ) : int[]

Called from Flush(). The return value determines whether the entity is updated

an array of property indicies - the entity is dirty an empty array - the entity is not dirty null - use Hibernate's default dirty-checking algorithm

Instantiate ( System entityName, EntityMode entityMode, object id ) : object

Instantiate the entity class. Return to indicate that Hibernate should use the default constructor of the class

The identifier property of the returned instance should be initialized with the given identifier.

IsTransient ( object entity ) : bool?

Called when a transient entity is passed to SaveOrUpdate.

The return value determines if the object is saved - the entity is passed to Save(), resulting in an INSERT - the entity is passed to Update(), resulting in an UPDATE - Hibernate uses the unsaved-value mapping to determine if the object is unsaved

OnDelete ( object entity, object id, object state, string propertyNames, IType types ) : void

Called before an object is deleted

It is not recommended that the interceptor modify the state.

OnFlushDirty ( object entity, object id, object currentState, object previousState, string propertyNames, IType types ) : bool

Called when an object is detected to be dirty, during a flush.

The interceptor may modify the detected currentState, which will be propagated to both the database and the persistent object. Note that all flushes end in an actual synchronization with the database, in which as the new currentState will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify the previousState.

OnLoad ( object entity, object id, object state, string propertyNames, IType types ) : bool

Called just before an object is initialized

The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class.

OnSave ( object entity, object id, object state, string propertyNames, IType types ) : bool

Called before an object is saved

The interceptor may modify the state, which will be used for the SQL INSERT and propagated to the persistent object

PostFlush ( ICollection entities ) : void

Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.

PreFlush ( ICollection entities ) : void

Called before a flush

Protected Methods

Method Description
HookDispatcher ( ) : System.Collections

Initializes a new instance of the HookDispatcher class.

Method Details

FindDirty() public method

Called from Flush(). The return value determines whether the entity is updated
an array of property indicies - the entity is dirty an empty array - the entity is not dirty null - use Hibernate's default dirty-checking algorithm
public FindDirty ( object entity, object id, object currentState, object previousState, string propertyNames, IType types ) : int[]
entity object A persistent entity
id object
currentState object
previousState object
propertyNames string
types IType
return int[]

HookDispatcher() protected method

Initializes a new instance of the HookDispatcher class.
protected HookDispatcher ( ) : System.Collections
return System.Collections

Instantiate() public method

Instantiate the entity class. Return to indicate that Hibernate should use the default constructor of the class
The identifier property of the returned instance should be initialized with the given identifier.
public Instantiate ( System entityName, EntityMode entityMode, object id ) : object
entityName System the name of the entity
entityMode EntityMode The type of entity instance to be returned.
id object the identifier of the new instance
return object

IsTransient() public method

Called when a transient entity is passed to SaveOrUpdate.
The return value determines if the object is saved - the entity is passed to Save(), resulting in an INSERT - the entity is passed to Update(), resulting in an UPDATE - Hibernate uses the unsaved-value mapping to determine if the object is unsaved
public IsTransient ( object entity ) : bool?
entity object A transient entity
return bool?

OnDelete() public method

Called before an object is deleted
It is not recommended that the interceptor modify the state.
public OnDelete ( object entity, object id, object state, string propertyNames, IType types ) : void
entity object
id object
state object
propertyNames string
types IType
return void

OnFlushDirty() public method

Called when an object is detected to be dirty, during a flush.
The interceptor may modify the detected currentState, which will be propagated to both the database and the persistent object. Note that all flushes end in an actual synchronization with the database, in which as the new currentState will be propagated to the object, but not necessarily (immediately) to the database. It is strongly recommended that the interceptor not modify the previousState.
public OnFlushDirty ( object entity, object id, object currentState, object previousState, string propertyNames, IType types ) : bool
entity object
id object
currentState object
previousState object
propertyNames string
types IType
return bool

OnLoad() public method

Called just before an object is initialized
The interceptor may change the state, which will be propagated to the persistent object. Note that when this method is called, entity will be an empty uninitialized instance of the class.
public OnLoad ( object entity, object id, object state, string propertyNames, IType types ) : bool
entity object
id object
state object
propertyNames string
types IType
return bool

OnSave() public method

Called before an object is saved
The interceptor may modify the state, which will be used for the SQL INSERT and propagated to the persistent object
public OnSave ( object entity, object id, object state, string propertyNames, IType types ) : bool
entity object
id object
state object
propertyNames string
types IType
return bool

PostFlush() public method

Called after a flush that actually ends in execution of the SQL statements required to synchronize in-memory state with the database.
public PostFlush ( ICollection entities ) : void
entities ICollection The entitites
return void

PreFlush() public method

Called before a flush
public PreFlush ( ICollection entities ) : void
entities ICollection The entities
return void