Hi. I have a simple question regarding transaction rollback.
When I execute the following code:
Code:
Transaction transaction1 = dbSession.beginTransaction();
// create persistant class 1
transaction1.rollback();
Transaction transaction2 = dbSession.beginTransaction();
// create persistant class 2
transaction2.commit();
both persistant classes 1 and 2 are stored in the database. I'm not sure I understand why.
One resolution I found for this is adding transaction1.flush() before transaction1.rollback(). However, I didn't notice any documentation/example in which rollback requried a flush or clear of the session.
Am I doing something wrong or missing something here?
I appreciate the help
Hibernate version: 3.1 final
Mapping documents: using annotations
Name and version of the database you are using: oracle 10g
The generated SQL (show_sql=true):
Hibernate: select ATTR_SEQ.nextval from dual
Hibernate: select ATTR_SEQ.nextval from dual
Hibernate: insert into STATIC_ATTR (CREATION_TIMESTAMP, PARENT_ID, PARENT_TYPE, PRIORITY_WEIGHT, NAME, TYPE, ID) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into STATIC_ATTR (CREATION_TIMESTAMP, PARENT_ID, PARENT_TYPE, PRIORITY_WEIGHT, NAME, TYPE, ID) values (?, ?, ?, ?, ?, ?, ?)