Hi Leonardo,

This is the dev group, this should be posted to the NH-Users group: http://groups.google.com/group/nhusers

My understanding is that there is no auto-flush of the session in NH outside a transaction. You can still use NH, but would have to manually flush changes to the database yourself.

In addition, bear in mind that all SQL in the database will be executed inside a transaction ... if you don't have one, then the SQL will be executed in autocommit mode: http://technet.microsoft.com/en-us/library/ms187878.aspx

Hope that helps.

Richard

--------------------------------------------------
From: "Leonardo Garcia Crespo" <[email protected]>
Sent: Tuesday, February 09, 2010 2:09 PM
To: "nhibernate-development" <[email protected]>
Subject: [nhibernate-development] Mandatory Transactions (how true is this?)

Hi!
I've seen that Fabio and Ayende a long time ago said that Transactions
are mandatory, even if only querying. They quoted the Hibernate
reference also.

I've seen all this, as I wasn't aware of this practise, so I decided
to apply it. But when I did that, I found it's taking a lot of time to
open a transaction (I have the DB in USA, and my app in dev
environment is running here, in Argentina, so it has a little round
trip time to call a begin transaction).

A request to a page from my site, without transactions, is lasting
400ms, where as with transaction, it lasts 800ms.
Only a simple Get is inside de transaction, and one lazy property
being called in the view (that is also inside the transaction).

So I started thinking, is this truly a good practise? What am I doing
wrong by using a transaction in this case? Should I return to using
transactions only when modifying entities? What are the problems I've
got if I don't use a transaction when only reading?

Thanks for anyone who can answer this!

Leonardo

Reply via email to