assertEquals("desc-2", persisted2.getDescription());
}
@Test
public void commitWithException() {
Transaction transaction = transactionContext.getCurrentTransaction();
MyEntity1 entity1 = new MyEntity1();
entity1.setId(createId("id-7"));
entity1.setDescription("desc-7");
assertFalse(transaction.isActive());
transaction.begin();
assertTrue(transaction.isActive());
em1.persist(entity1);
transaction.commit();
em1.clear();
entity1 = new MyEntity1();
entity1.setId(createId("id-7"));
entity1.setDescription("desc-7");
assertFalse(transaction.isActive());
transaction.begin();
assertTrue(transaction.isActive());
em1.persist(entity1);
try {
transaction.commit();
Assert.fail();
}
catch(TransactionException te) {
te.printStackTrace();
//success