Package org.hibernate.envers.test.entities.manytomany.biowned

Examples of org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning2Entity


    public void initData() {
        EntityManager em = getEntityManager();

        ListBiowning1Entity o1_1 = new ListBiowning1Entity("o1_1");
        ListBiowning1Entity o1_2 = new ListBiowning1Entity("o1_2");
        ListBiowning2Entity o2_1 = new ListBiowning2Entity("o2_1");
        ListBiowning2Entity o2_2 = new ListBiowning2Entity("o2_2");

        // Revision 1
        em.getTransaction().begin();

        em.persist(o1_1);
        em.persist(o1_2);
        em.persist(o2_1);
        em.persist(o2_2);

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

        // Revision 2 (1_1 <-> 2_1; 1_2 <-> 2_2)

        em.getTransaction().begin();

        o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
        o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
        o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
        o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());

        o1_1.getReferences().add(o2_1);
        o1_2.getReferences().add(o2_2);

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

        // Revision 3 (1_1 <-> 2_1, 2_2; 1_2 <-> 2_2)
        em.getTransaction().begin();

        o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
        o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());

        o1_1.getReferences().add(o2_2);

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

        // Revision 4 (1_2 <-> 2_1, 2_2)
        em.getTransaction().begin();

        o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
        o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
        o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
        o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());

        o2_2.getReferences().remove(o1_1);
        o2_1.getReferences().remove(o1_1);
        o2_1.getReferences().add(o1_2);

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

        // Revision 5 (1_1 <-> 2_2, 1_2 <-> 2_2)
        em.getTransaction().begin();

        o1_1 = em.find(ListBiowning1Entity.class, o1_1.getId());
        o1_2 = em.find(ListBiowning1Entity.class, o1_2.getId());
        o2_1 = em.find(ListBiowning2Entity.class, o2_1.getId());
        o2_2 = em.find(ListBiowning2Entity.class, o2_2.getId());

        o1_2.getReferences().remove(o2_1);
        o1_1.getReferences().add(o2_2);

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

        //

        o1_1_id = o1_1.getId();
        o1_2_id = o1_2.getId();
        o2_1_id = o2_1.getId();
        o2_2_id = o2_2.getId();
    }
View Full Code Here


        assertEquals(Arrays.asList(1, 4), getAuditReader().getRevisions(ListBiowning2Entity.class, o2_2_id));
    }

    @Test(enabled = true)
    public void testHistoryOfO1_1() {
        ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
        ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);

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

        assert TestTools.checkList(rev5.getReferences(), o2_2);
    }

    @Test(enabled = true)
    public void testHistoryOfO1_2() {
        ListBiowning2Entity o2_1 = getEntityManager().find(ListBiowning2Entity.class, o2_1_id);
        ListBiowning2Entity o2_2 = getEntityManager().find(ListBiowning2Entity.class, o2_2_id);

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

    @Test(enabled = true)
    public void testHistoryOfO2_1() {
        ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
        ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);

        ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 1);
        ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 2);
        ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 3);
        ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 4);
        ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_1_id, 5);

        assert TestTools.checkList(rev1.getReferences());
        assert TestTools.checkList(rev2.getReferences(), o1_1);
        assert TestTools.checkList(rev3.getReferences(), o1_1);
        assert TestTools.checkList(rev4.getReferences(), o1_2);
        assert TestTools.checkList(rev5.getReferences());
    }
View Full Code Here

    @Test(enabled = true)
    public void testHistoryOfO2_2() {
        ListBiowning1Entity o1_1 = getEntityManager().find(ListBiowning1Entity.class, o1_1_id);
        ListBiowning1Entity o1_2 = getEntityManager().find(ListBiowning1Entity.class, o1_2_id);

        ListBiowning2Entity rev1 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 1);
        ListBiowning2Entity rev2 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 2);
        ListBiowning2Entity rev3 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 3);
        ListBiowning2Entity rev4 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 4);
        ListBiowning2Entity rev5 = getAuditReader().find(ListBiowning2Entity.class, o1_2_id, 5);

        assert TestTools.checkList(rev1.getReferences());
        assert TestTools.checkList(rev2.getReferences(), o1_2);
        assert TestTools.checkList(rev3.getReferences(), o1_1, o1_2);
        assert TestTools.checkList(rev4.getReferences(), o1_2);
        assert TestTools.checkList(rev5.getReferences(), o1_1, o1_2);
    }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.test.entities.manytomany.biowned.ListBiowning2Entity

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.