*/
public class BasicTransactionTest extends BaseJPAFTest {
@Test
public void testPersistDetachedEntityFromRollback() {
AccountEntity entity = new AccountEntity();
entity.setName("BasicTransactionTest.testPersistDetachedEntityFromRollback");
EntityTransaction transaction = em.getTransaction();
transaction.begin();
em.persist(entity);
transaction.rollback();
Assert.assertNull(entity.getId(), "expected a null id for rolled back entity, but got: " + entity.getId());
Assert.assertFalse(em.contains(entity),
"Transaction was rolled back, yet the entity manager still contains the persisted entity.");
transaction = em.getTransaction();
transaction.begin();
em.persist(entity);
transaction.commit();
Assert.assertNotNull(entity.getId(), "expected an id after entity was committed, but the id was null");
Assert.assertNotNull(em.find(AccountEntity.class, entity.getId()).getName(),
"expected a result from retrieving the committed entity from the db, but received a null result");
}