david wrote:
Did you flush the session before rolling back? This syncs with the db and thus enables it for rollback. Alternative is the evict it from the session cache.
Here is the testing code:
Code:
SessionFactory sessionFactory = new Configuration().configure("/hibernate.cfg.xml").buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction tx = (Transaction)session.beginTransaction();
ExternalSystemPO newExtSystemOne = new ExternalSystemPO(EXTERNAL_SYS_KEY_ONE);
session.save(newExtSystemOne);
session.flush();
tx.rollback();
session.flush() does not seem to make a difference. I will test session.evict() method to see if it works.