John,

1. Your example does not Dispose the session when you are finished. This is
something that must be done in *all* situations.
2. NHibernate more or less only works correctly when using the NHibernate
transaction AFAIK. That is the pattern NHibernate is using no matter what
environment.
3. The reason why you should not create a session out-side of the
transaction is becuase you could trigger modifications in the first level
cache which would then not be done within a transaction. Reads must also be
part of the same transaction.
4. AFAIK You cannot use 2nd level cache when using distributed transactions.


I agree that it is too bad that NHibernate does not have implicit
transactions when a Session is created within a TransactionScope but it
isn't really that hard to put this logic especially when you consider that
you should just always immediately begin an nhibernate transaction after
you have created the session.

--
Ramon

Reply via email to