Hi guys, thank you for your help in advance.
I've discovered something that I hope is due to my own ignorance somehow and not due to a bug in Hibernate (which is a great product, btw). Anycase, Im having a system where Im retaining the DAO objects as business objects for a while and I need a system to rollback changes to the DAOs if a persist exception occurs, like a SQLException or such. To do this I'm utilizing a callback on PostUpdateEventListener. Im working uder assumption that if the Transaction was rolled back that there was some sort of an error.
However, after thorough debugging, I noticed that the object Transaction extracted from SessionImpl gotten from PostUpdateEvent obj is a different Transaction obj then the one I see on the session before tran.rollback() is called. I can tell because all the fields in this Transaction are set to false (commited, rolledback, begun, etc) as well as Eclipse's id for this object is different. HOWEVER, I CAN VERIFY THAT SESSION OBJECT IS STILL THE SAME, with Ecliplse's id and all the fields' values. I was getting the session via PostUpdateEvent.getSession() and Transaction via PostUpdateEvent.getSession().getTransaction(). When the processing returned to after the original tran.rollback() call, the old proper Transaction obj is returned from session.getTransaction(), complete with all the fields set to proper values (begun=true, rolledBack=true, etc).
Is this a bug in the handling of transactions or am I missing something? Thank you all for your responses in advance again.
I suspect similar might be in play with PostInsertEventListener and PostDeleteEventListener but havent verified yet.
|