NHibernate operations in Open View per session - suggested practice?

Cleaning up some transactional logic and wondering how other people handle it.

Ayende's recommendation seems to be for service edge transaction processing. It's an ASP.NET web application, although it doesn't have a clear service boundary, at least not right now.

What are people doing?

  • Create a single transaction for each request in the HttpModule and handle the commit to EndRequest, rollback on error?
  • Create transactions in real "services" in the application and process them in multiple places?
  • Something else?
+1


source to share


2 answers


Most people use the session per request strategy as stated in your first starting point. However, I do not believe that the transaction should be committed on EndRequest. On many web pages, it would be easier to commit a transaction based on a user action (for example, clicking the Submit button) and let EndRequest simply handle the removal of the ISession.



As far as I can tell, there is no need to create an HttpModule as the same functionality can be created in global.asax: http://forum.hibernate.org/viewtopic.php?t=993041 .

0


source


You can use an IoC container for your service level, and the container can manage the Nibenrate transaction and session.

Your WebApp Controller => call (A) Service Layer => call (B) one or more DAO methods / operations.



An IoC container like Spring.NET will manage the TX TX scope in (A) for example and provide a Session for your DAO in (B). The end (or rollback) will be handled at the end of the service level call.

+1


source







All Articles