Package org.apache.openjpa.persistence.entity

Examples of org.apache.openjpa.persistence.entity.EntityB


   
    public void testOpenJPA2330() {
        final EntityManager em = emf.createEntityManager();

        EntityA a = new EntityA();
        EntityB b = new EntityB(a);
        // set back pointer
        a.getBs().add(b);
       
        EntityC c = new EntityC(b);
        // set back pointer
        b.getCs().add(c);

        em.persist(a);
        em.persist(b);
        em.persist(c);
       
View Full Code Here


   
    public void testOpenJPA2330() {
        final EntityManager em = emf.createEntityManager();

        EntityA a = new EntityA();
        EntityB b = new EntityB(a);
        // set back pointer
        a.getBs().add(b);
       
        EntityC c = new EntityC(b);
        // set back pointer
        b.getCs().add(c);

        em.persist(a);
        em.persist(b);
        em.persist(c);
       
View Full Code Here

        EntityManager em = emf.createEntityManager();

        em.getTransaction().begin();
        EntityA a = new EntityA();

        EntityB b1 = new EntityB(a);
        b1.setName("b1");
        a.getBs().add(b1);

        EntityB b2 = new EntityB(a);
        b2.setName("b2");
        a.getBs().add(b2);

        EntityB b3 = new EntityB(a);
        b3.setName("b3");
        a.getBs().add(b3);

        EntityB b4 = new EntityB(a);
        b4.setName("b4");
        a.getBs().add(b4);

        em.persist(a);

        em.getTransaction().commit();
        em.close();

        // now read all back in
        em = emf.createEntityManager();
        em.getTransaction().begin();
        EntityA a2 = em.find(EntityA.class, a.getId());
        Assert.assertNotNull(a2);
        Assert.assertNotNull(a2.getBs());
        Assert.assertEquals(4, a2.getBs().size());

        Iterator<EntityB> it = a2.getBs().iterator();
        for (int i = 1; i <= 4; i++) {
            EntityB entityB = it.next();

            Assert.assertEquals("b" + i, entityB.getName());
        }

        em.getTransaction().commit();
        em.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.persistence.entity.EntityB

Copyright © 2018 www.massapicom. 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.