use of org.datanucleus.samples.annotations.callbacks.CallbackSub2 in project tests by datanucleus.
the class CallbackTest method testExpectionInCallbackNotEaten.
public void testExpectionInCallbackNotEaten() {
try {
EntityManager em = getEM();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
CallbackSub2 d = new CallbackSub2();
d.setName("dpt1");
d.setId("1");
em.persist(d);
em.flush();
fail("Expected ArithmeticException");
} catch (ArithmeticException ex) {
// expected
} finally {
CallbackBase.invoked.clear();
CallbackSub1Listener.invoked.clear();
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
} finally {
clean(CallbackSub2.class);
}
}
Aggregations