}
public void testPostPersist() {
// regular entity
CallbackEntity e = new CallbackEntity();
assertFalse(e.isPostPersistCalled());
// don't use super getEntityManager - it starts a tran
EntityManager em = ItestSetup.getInstance().createEntityManager();
// spec reqires the callback to be invoked as a part of persist, without waiting
// for flush or commit.
em.getTransaction().begin();
em.persist(e);
assertFalse(e.isPostPersistCalled());
assertEquals(0, e.getPostPersistedId());
em.getTransaction().commit();
assertTrue(e.isPostPersistCalled());
// Per spec, id must be availble during PostPersist
assertEquals(e.getId(), e.getPostPersistedId());
assertTrue(e.getId() > 0);
// external listeners
EntityListenerState.reset();
assertEquals("", EntityListenerState.getPostPersistCalled());
ListenerEntity1 e3 = new ListenerEntity1();