Examples of ListJoinColumnBidirectionalRefIngEntity


Examples of org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidirectionalRefIngEntity

        EntityManager em = getEntityManager();

        ListJoinColumnBidirectionalRefEdEntity ed1 = new ListJoinColumnBidirectionalRefEdEntity("ed1", null);
        ListJoinColumnBidirectionalRefEdEntity ed2 = new ListJoinColumnBidirectionalRefEdEntity("ed2", null);

        ListJoinColumnBidirectionalRefIngEntity ing1 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed1);
        ListJoinColumnBidirectionalRefIngEntity ing2 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed2);

        // Revision 1 (ing1: ed1, ing2: ed2)
        em.getTransaction().begin();

        em.persist(ed1);
        em.persist(ed2);
        em.persist(ing1);
        em.persist(ing2);

        em.getTransaction().commit();

        // Revision 2 (ing1: ed1, ed2)
        em.getTransaction().begin();

        ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
        ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
        ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
        ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());

        ing2.getReferences().remove(ed2);
        ing1.getReferences().add(ed2);

        em.getTransaction().commit();
        em.clear();

        // No revision - no changes
        em.getTransaction().begin();

        ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
        ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
        ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
        ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());

        ed2.setOwner(ing2);

        em.getTransaction().commit();
        em.clear();

        // Revision 3 (ing1: ed1, ed2)
        em.getTransaction().begin();

        ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());

        ed1.setData("ed1 bis");
        // Shouldn't get written
        ed1.setOwner(ing2);

        em.getTransaction().commit();
        em.clear();

        // Revision 4 (ing2: ed1, ed2)
        em.getTransaction().begin();

        ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
        ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());

        ing1.getReferences().clear();
        ing2.getReferences().add(ed1);
        ing2.getReferences().add(ed2);

        em.getTransaction().commit();
        em.clear();

        //

        ing1_id = ing1.getId();
        ing2_id = ing2.getId();

        ed1_id = ed1.getId();
        ed2_id = ed2.getId();
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidirectionalRefIngEntity

    public void testHistoryOfIng1() {
        ListJoinColumnBidirectionalRefEdEntity ed1_fromRev1 = new ListJoinColumnBidirectionalRefEdEntity(ed1_id, "ed1", null);
        ListJoinColumnBidirectionalRefEdEntity ed1_fromRev3 = new ListJoinColumnBidirectionalRefEdEntity(ed1_id, "ed1 bis", null);
        ListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id);

        ListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 1);
        ListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 2);
        ListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 3);
        ListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id, 4);

        assertTrue(checkList(rev1.getReferences(), ed1_fromRev1));
        assertTrue(checkList(rev2.getReferences(), ed1_fromRev1, ed2));
        assertTrue(checkList(rev3.getReferences(), ed1_fromRev3, ed2));
        assertTrue(checkList(rev4.getReferences()));
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidirectionalRefIngEntity

    @Test(enabled = true, dependsOnMethods = "createData")
    public void testHistoryOfIng2() {
        ListJoinColumnBidirectionalRefEdEntity ed1 = getEntityManager().find(ListJoinColumnBidirectionalRefEdEntity.class, ed1_id);
        ListJoinColumnBidirectionalRefEdEntity ed2 = getEntityManager().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id);

        ListJoinColumnBidirectionalRefIngEntity rev1 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 1);
        ListJoinColumnBidirectionalRefIngEntity rev2 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 2);
        ListJoinColumnBidirectionalRefIngEntity rev3 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 3);
        ListJoinColumnBidirectionalRefIngEntity rev4 = getAuditReader().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id, 4);

        assertTrue(checkList(rev1.getReferences(), ed2));
        assertTrue(checkList(rev2.getReferences()));
        assertTrue(checkList(rev3.getReferences()));
        assertTrue(checkList(rev4.getReferences(), ed1, ed2));
    }
View Full Code Here

Examples of org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidirectionalRefIngEntity

        assertTrue(checkList(rev4.getReferences(), ed1, ed2));
    }

    @Test(enabled = true, dependsOnMethods = "createData")
    public void testHistoryOfEd1() {
        ListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
        ListJoinColumnBidirectionalRefIngEntity ing2 = getEntityManager().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id);

        ListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 1);
        ListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 2);
        ListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 3);
        ListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed1_id, 4);
View Full Code Here

Examples of org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidirectionalRefIngEntity

        assertEquals(rev4.getData(), "ed1 bis");
    }

    @Test(enabled = true, dependsOnMethods = "createData")
    public void testHistoryOfEd2() {
        ListJoinColumnBidirectionalRefIngEntity ing1 = getEntityManager().find(ListJoinColumnBidirectionalRefIngEntity.class, ing1_id);
        ListJoinColumnBidirectionalRefIngEntity ing2 = getEntityManager().find(ListJoinColumnBidirectionalRefIngEntity.class, ing2_id);

        ListJoinColumnBidirectionalRefEdEntity rev1 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 1);
        ListJoinColumnBidirectionalRefEdEntity rev2 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 2);
        ListJoinColumnBidirectionalRefEdEntity rev3 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 3);
        ListJoinColumnBidirectionalRefEdEntity rev4 = getAuditReader().find(ListJoinColumnBidirectionalRefEdEntity.class, ed2_id, 4);
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.