I am using the following generic code to save entities.
using (ITransaction tx = session.BeginTransaction()) { try { entity.DateModified = DateTime.Now; session.SaveOrUpdate(entity); session.Flush(); tx.Commit(); return entity; } catch (Exception) { tx.Rollback(); throw; } }
However, when I watch SQL Profiler I don’t see any BEGIN TRANSACTION being sent to SQL Server. Is this normal, expected?
I’ll suggest the obvious: make sure Profiler is set to display transaction information.
In the Trace Properties dialog -> Events selection tab, there’s an expando for Transactions. Open it up and check the appropriate boxes (or just check ’em all on).
Also, FYI: I checked our application that uses NHibernate, and yes I do see BEGIN TRANSACTION and COMMIT TRANSACTION calls while tracing in Profiler.