I'm not sure if this is correct, but I need that after a transaction is rollbacked, my object returns the its initial state. I created a junit test and it's failing.
try {
entityManager.getTransaction().begin();
entityManager.persist(itemBec);
// throw new Exception("teste");
// throw new EJBTransactionRolledbackException("teste");
// throw new ConstraintViolationException("teste", null, null);
throw new RuntimeException("teste");
} catch (Exception e) {
entityManager.getTransaction().rollback();
} finally {
if (entityManager.getTransaction().isActive()) {
entityManager.getTransaction().commit();
}
}
entityManager.close();
factory.close();
Assert.assertNull(itemBec.getId());
Am I wrong to assume that the object must return do its initial state?
Thanks.