Reputation: 13722
Where can I find a good reference on NHibernate events and what the lifecycle for each looks like? There seem to be several events and without proper documentation it's hard to know for sure what differences between the various events are.
Sure there are obvious ones like OnSaveOrUpdate
- but there are also non-obvious ones like ILoadEventListener
vs IPreLoadEventListener
vs IPostLoadEventListener
Upvotes: 2
Views: 2911
Reputation: 15303
The only official documentation that I know of is here: http://nhibernate.info/doc/nhibernate-reference/index.html
The following is an excerpt from this documentation that describes the event system. The events that you mention above are listeners based on the Load
method in the ISession
interface.
If you have to react to particular events in your persistence layer, you may also use the NHibernate2 event architecture. The event system can be used in addition or as a replacement for interceptors.
Essentially all of the methods of the ISession interface correlate to an event. You have a LoadEvent, a FlushEvent, etc (consult the XML configuration-file XSD or the NHibernate.Event namespace for the full list of defined event types). When a request is made of one of these methods, the ISession generates an appropriate event and passes it to the configured event listeners for that type. Out-of-the-box, these listeners implement the same processing in which those methods always resulted. However, you are free to implement a customization of one of the listener interfaces (i.e., the LoadEvent is processed by the registered implemenation of the ILoadEventListener interface), in which case their implementation would be responsible for processing any Load() requests made of the ISession.
As with any open source tool though sometimes you just need to download the source and either look at the comments or the code itself.
In addition to looking at the code there are numerous books out there on nhibernate that might be helfpul for you as well.
NHibernate 3.0 Cookbook http://www.packtpub.com/nhibernate-3-0-cookbook/book
NHibernate 3 Beginner's Guide http://www.packtpub.com/nhibernate-3-beginners-guide/book (I recommend this book)
Working with NHibernate 3.0 http://www.wrox.com/WileyCDA/WroxTitle/Working-with-NHibernate-3-0.productCd-1118112571.html
Upvotes: 3