I have something like this:
Code:
try{
MyClass myClass = new MyClass();
dao.save(myClass);
sf.getCurrentSession().flush(); // Saving object.
// In this place I’m using PreparedStatement to save some data, I’m creating sql and
// executing. During creating sql I’m pass id myClass (create relation one to many).
} catch (Exception ex) {
// Now if appear some error during executing sql I wont rollback all also myClass.
// so I call.
sf.getCurrentSession().setFlushMode(FlushMode.MANUAL);
}
But this method rollback only sql executed through PreparedStatement, myClass is still in database, why? Can I rollback all using FlushMode.MANUAL.
I know I can use “dao.getSession().beginTransaction();” before TRY and “dao.getSession().getTransaction().rollback();” in catch and all is rollback, but can I do this using “FlushMode.MANUAL”