NHibernate Transactions Best Practices?

It really depends on your environment. For example, we use the Open-Session-In-View (Java link but the pattern is the same in . Net) pattern on an ASP.Net site and use an HttpModule for controlling sessions and transactions.

The HttpModule opens a session and starts a transaction in the BeginRequest event and then commits the transaction and closes the session in the EndRequest event.

It really depends on your environment. For example, we use the Open-Session-In-View (Java link but the pattern is the same in . Net) pattern on an ASP.Net site and use an HttpModule for controlling sessions and transactions.

The HttpModule opens a session and starts a transaction in the BeginRequest event and then commits the transaction and closes the session in the EndRequest event. Different environments and communication patterns will lead to different session/transaction management strategies. There is a lot of discussion on the various strategies in the Nbernate Users Group as well as on the web in general.

Based on Ayende, you probably need to explicitly add transaction for all, even searching. Please check here: nhprof.com/Learn/Alerts/DoNotUseImplicit....

Simplest way is to use Smart Transaction described in rajputyh.blogspot.com/2011/02/nested-tra... It uses popular NbernateSessionManager and a simple class is written to ensure that "you open transaction when you want" without worrying about what parent logic and sub logic is handling transaction.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions