Is it at all possible that calls to sess.flush() would cause the transaction to commit? I've been debugging a problem where we're rolling back a transaction, but changes are still being committed.
Here is what I am doing...
Code:
try{
begin tx;
sess.update(obj); // causes version update
sess.flush();
do some more updates to other objects;
sess.flush();
do some more updates to yet other objects;
sess.flush();
throw new Exception(); // debugging exception thrown.
// commit would normally be here;
} catch (Exception e) {
rollback tx;
} finally {
close sess;
}
I'm flushing at each point because I'm capturing timing information for each step. It's not necessary, but I thought that flush() just caused the SQL statements to be sent to the database. If I get rid of the second two flushes, the first object's version number gets committed to the db. If I get rid of all the flushes, everything rolls back as expected.
Does anyone know what could be causing the problem? Thanks in advance.
-Matt
Code: