NHibernate Transactions on Reads

This post from one of the authors might have your answer:

Even if we are only reading data, we
want to use a transaction, because
using a transaction ensure that we get
a consistent result from the database.
NHibernate assume that all access to
the database is done under a
transaction, and strongly discourage
any use of the session without a
transaction.

Leaving aside the safety issue of
working with transactions, the
assumption that transactions are
costly and we need to optimize them is
a false one. As already mentioned,
databases are always running in
transaction. And databases have been
heavily optimized to work with
transactions. The question is whatever
this is per statement or per batch.
There is some amount of work that need
to be done to create and dispose a
transaction, and having to do it per
statement is actually more costly than
doing it per batch.

Leave a Comment