Package org.hibernate.envers.test.entities.onetomany.ids

Examples of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity


        // Revision 1
        EntityManager em = getEntityManager();
        em.getTransaction().begin();

        SetRefIngMulIdEntity refIng1 = new SetRefIngMulIdEntity(id1, "x", null);
        SetRefIngMulIdEntity refIng2 = new SetRefIngMulIdEntity(id2, "y", null);

        em.persist(refIng1);
        em.persist(refIng2);

        em.getTransaction().commit();

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

        SetRefEdMulIdEntity refEd3 = new SetRefEdMulIdEntity(id3, "a");
        SetRefEdMulIdEntity refEd4 = new SetRefEdMulIdEntity(id4, "a");

        em.persist(refEd3);
        em.persist(refEd4);

        refIng1 = em.find(SetRefIngMulIdEntity.class, id1);
        refIng2 = em.find(SetRefIngMulIdEntity.class, id2);

        refIng1.setReference(refEd3);
        refIng2.setReference(refEd4);

        em.getTransaction().commit();

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

        refEd3 = em.find(SetRefEdMulIdEntity.class, id3);
        refIng2 = em.find(SetRefIngMulIdEntity.class, id2);
        refIng2.setReference(refEd3);

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


        assert rev1.equals(rev1_related);
        assert rev2.equals(rev2_related);
        assert rev3.equals(rev3_related);

        assert rev1.equals(TestTools.makeSet());
        assert rev2.equals(TestTools.makeSet(new SetRefIngMulIdEntity(id1, "x", null)));
        assert rev3.equals(TestTools.makeSet(new SetRefIngMulIdEntity(id1, "x", null),
                new SetRefIngMulIdEntity(id2, "y", null)));
    }
View Full Code Here

                .forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3)
                .add(AuditEntity.relatedId("reference").eq(id4))
                .getResultList());

        assert rev1_related.equals(TestTools.makeSet());
        assert rev2_related.equals(TestTools.makeSet(new SetRefIngMulIdEntity(id2, "y", null)));
        assert rev3_related.equals(TestTools.makeSet());
    }
View Full Code Here

                .add(AuditEntity.relatedId("reference").eq(id3))
                .add(AuditEntity.id().eq(id1))
                .getSingleResult();

        assert rev1_related.size() == 0;
        assert rev2_related.equals(new SetRefIngMulIdEntity(id1, "x", null));
        assert rev3_related.equals(new SetRefIngMulIdEntity(id1, "x", null));
    }
View Full Code Here

                .add(AuditEntity.id().eq(id2))
                .getSingleResult();

        assert rev1_related.size() == 0;
        assert rev2_related.size() == 0;
        assert rev3_related.equals(new SetRefIngMulIdEntity(id2, "y", null));
    }
View Full Code Here

        EntityManager em = getEntityManager();

        SetRefEdMulIdEntity ed1 = new SetRefEdMulIdEntity(ed1_id.getId1(), ed1_id.getId2(), "data_ed_1");
        SetRefEdMulIdEntity ed2 = new SetRefEdMulIdEntity(ed2_id.getId1(), ed2_id.getId2(), "data_ed_2");

        SetRefIngMulIdEntity ing1 = new SetRefIngMulIdEntity(ing1_id.getId1(), ing1_id.getId2(), "data_ing_1", ed1);
        SetRefIngMulIdEntity ing2 = new SetRefIngMulIdEntity(ing2_id.getId1(), ing2_id.getId2(), "data_ing_2", ed1);

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

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

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

        em.getTransaction().commit();

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

        ing1 = em.find(SetRefIngMulIdEntity.class, ing1_id);
        ed2 = em.find(SetRefEdMulIdEntity.class, ed2_id);

        ing1.setReference(ed2);

        em.getTransaction().commit();

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

        ing2 = em.find(SetRefIngMulIdEntity.class, ing2_id);
        ed2 = em.find(SetRefEdMulIdEntity.class, ed2_id);

        ing2.setReference(ed2);

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

        return ret;
    }

    @Test
    public void testHistoryOfEdId1() {
        SetRefIngMulIdEntity ing1 = getEntityManager().find(SetRefIngMulIdEntity.class, ing1_id);
        SetRefIngMulIdEntity ing2 = getEntityManager().find(SetRefIngMulIdEntity.class, ing2_id);

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

        assert rev3.getReffering().equals(Collections.EMPTY_SET);
    }

    @Test
    public void testHistoryOfEdId2() {
        SetRefIngMulIdEntity ing1 = getEntityManager().find(SetRefIngMulIdEntity.class, ing1_id);
        SetRefIngMulIdEntity ing2 = getEntityManager().find(SetRefIngMulIdEntity.class, ing2_id);

        SetRefEdMulIdEntity rev1 = getAuditReader().find(SetRefEdMulIdEntity.class, ed2_id, 1);
        SetRefEdMulIdEntity rev2 = getAuditReader().find(SetRefEdMulIdEntity.class, ed2_id, 2);
        SetRefEdMulIdEntity rev3 = getAuditReader().find(SetRefEdMulIdEntity.class, ed2_id, 3);
View Full Code Here

    @Test
    public void testHistoryOfEdIng1() {
        SetRefEdMulIdEntity ed1 = getEntityManager().find(SetRefEdMulIdEntity.class, ed1_id);
        SetRefEdMulIdEntity ed2 = getEntityManager().find(SetRefEdMulIdEntity.class, ed2_id);

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

        assert rev1.getReference().equals(ed1);
        assert rev2.getReference().equals(ed2);
        assert rev3.getReference().equals(ed2);
    }
View Full Code Here

    @Test
    public void testHistoryOfEdIng2() {
        SetRefEdMulIdEntity ed1 = getEntityManager().find(SetRefEdMulIdEntity.class, ed1_id);
        SetRefEdMulIdEntity ed2 = getEntityManager().find(SetRefEdMulIdEntity.class, ed2_id);

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

        assert rev1.getReference().equals(ed1);
        assert rev2.getReference().equals(ed1);
        assert rev3.getReference().equals(ed2);
    }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity

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.