Hi. I'm hoping someone here can confirm this is a bug in NHibernate (v. 1.0.2):
If flush() is called after ITransaction.Rollback(), the data in the transaction is NOT rolled back unless a flush has already been executed.
To duplicate:
Code:
trans = session.BeginTransaction();
MyObj root = session.Load(typeof(MyObj), id);
MyObj.Name ="Changed Value";
trans.Rollback();
session.Flush();
The change is saved! This means that I need to be careful not to invoke any code that might trigger a flush in any finally clause in my application. Seems like a bug.
Note that in contrast to the above, if a flush occurs prior to the rollback, the transaction begins in the DB like you'd expect. In other words, the following code works fine:
Code:
trans = session.BeginTransaction();
MyObj root = session.Load(typeof(MyObj), id);
MyObj.Name ="Changed Value";
session.Flush();
trans.Rollback();
session.Flush();
It seems clear that at least one of these two behaviors is incorrect. Can someone let me know how to resolve this?