Hi all!
I recently started investigating NHibernate for use at our company, and find it extremely helpful. It tremendously speeds up the development timeline.
However, I have a question regarding the lifetime of an object. I have read other threads on the topic, and agree that I find IValidate somewhat unusable, because I don't know when and how many times the call to Validate() will be made. So, for now, I have put my Business Logic/Validation code in ILifecycle.OnSave(ISession) and ILifecycle.OnUpdate(ISession) callbacks. This works pretty well.
However, I want to make some updates to the object when the Save() or Update() is done! I would be really-really cool if ILifecycle offered "Post" events, and not just "Pre" events. In other words, it offered 8 methods:
Code:
LifecycleVeto OnDelete(...) //Called before an object is deleted
void OnDelete_Complete(...) // Called when an object has been deleted!
void OnLoad(...) // Before Loading
void OnLoad_Complete(...) // After Loading
(you get the idea).
QUESTION: With the current NHibernate, how do I achieve the equivalent of OnSave_Complete() callback??
(What I want to do is make some changes in the system based on identity generated Primary Key. I don't even mind updating NHibernate code and building it myself, but could someone point me to the right direction?).
I looked into "IInterceptor" interface as well. I don't want to override the default implementation of FindDirty(..), IsUnsaved(..) etc, so, I am unable to use the "IInterceptor" api as well at the moment.
Thanks for your help,
Desiguy
{btw: I am using NHibernate 1.2.0 Beta 2 against SQL Server 2005.}