Provides callbacks from the ISession to the persistent object. Persistent classes may implement this interface but they are not required to.

Namespace: NHibernate.Classic
Assembly: NHibernate (in NHibernate.dll) Version: 3.2.0.4000 (3.2.0.4000)

Syntax

C#
public interface ILifecycle
Visual Basic
Public Interface ILifecycle
Visual C++
public interface class ILifecycle

Remarks

OnSave(ISession), OnDelete(ISession), and OnUpdate(ISession) are intended to be used to cascade saves and deletions of dependent objects. This is an alternative to declaring cascaded operations in the mapping file.

OnLoad(ISession, Object) may be used to initialize transient properties of the object from its persistent state. It may not be used to load dependent objects since the ISession interface may not be invoked from inside this method.

A further intended usage of OnLoad(ISession, Object), OnSave(ISession), and OnUpdate(ISession) is to store a reference to the ISession for later use.

If OnSave(ISession), OnUpdate(ISession), or OnDelete(ISession) return Veto, the operation is silently vetoed. If a CallbackException is thrown, the operation is vetoed and the exception is passed back to the application.

Note that OnSave(ISession) is called after an identifier is assigned to the object, except when identity key generation is used.

See Also