How can I confirm that NHibernate is actually using a transaction using SQL Profiler?

I use the following general 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 look at SQL Profiler, I do not see the BEGIN TRANSACTION sending to SQL Server. Is this normal, expected?

+4
source share
2 answers

I suggest the obvious: make sure Profiler is configured to display transaction information.

In the dialog box โ€œTracing properties โ†’ tabโ€œ Event selection โ€there isโ€œ expando for Transactions. โ€Open it and check the corresponding fields (or just check all of them).

Also, FYI: I tested our application that uses NHibernate, and yes, I see BEGIN TRANSACTION and COMMIT TRANSACTION calls during tracing in Profiler.

+7
source

Try to complete the transaction, and then clear the session.

0
source

All Articles