Examples of CallbackEntity


Examples of org.apache.cayenne.jpa.itest.ch3.entity.CallbackEntity

public class _3_5_1_LifecycleCallbackMethodsTest extends EntityManagerCase {

    public void testPrePersist() {

        // regular entity
        CallbackEntity e = new CallbackEntity();
        assertFalse(e.isPrePersistCalled());

        EntityManager em = getEntityManager();

        // spec reqires the callback to be invoked as a part of persist, without waiting
        // for flush or commit.
        em.persist(e);
        assertTrue(e.isPrePersistCalled());

        // entity with same callback method handling multiple callbacks
        CallbackEntity2 e2 = new CallbackEntity2();
        assertFalse(e2.isMixedCallbackCalled());
        em.persist(e2);
View Full Code Here

Examples of org.apache.cayenne.jpa.itest.ch3.entity.CallbackEntity

    }

    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();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.