Hello! I'm a new NHibernate user, and I've been struggling with an issue for a couple of days, however I think I figured out what the problem is - I just need to confirm that this is, indeed, how NHibernate is supposed to work.
In my code, I have a mixture of using ISession.Save() as well as custom SQL queries (I've also used Named Queries, but the result was the same).
Code:
this.dataAccessManager.Save(o);
this.dataAccessManager.CreateUpdateQuery("UPDATE " + tableName + " SET createdBy=:createdBy WHERE id=:uid", parameters);
All of these are wrapped in the same transaction, however, the ordering of these statements is very important. The object obviously must be saved first before the update statement is executed.
Looking at the logs, it seems as though whenever IQuery.ExecuteUpdate() is called, the command is enlisted in the transaction immediately, whereas the ISession.Save() commands aren't enlisted in the transaction until ISession.Transaction.Commit() is invoked.
I suppose that this behaviour makes sense, but is there a way to have the ISession.Save() method enlist the database command into the active transaction immediately, rather than waiting for the Commit() method to be called?
Please let me know if you need more information - and thanks in advance!