Search in sources :

Example 6 with SetRefEdEmbIdEntity

use of org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity in project hibernate-orm by hibernate.

the class BasicSetWithEmbId method testHistoryOfEdId1.

@Test
public void testHistoryOfEdId1() {
    SetRefIngEmbIdEntity ing1 = getEntityManager().find(SetRefIngEmbIdEntity.class, ing1_id);
    SetRefIngEmbIdEntity ing2 = getEntityManager().find(SetRefIngEmbIdEntity.class, ing2_id);
    SetRefEdEmbIdEntity rev1 = getAuditReader().find(SetRefEdEmbIdEntity.class, ed1_id, 1);
    SetRefEdEmbIdEntity rev2 = getAuditReader().find(SetRefEdEmbIdEntity.class, ed1_id, 2);
    SetRefEdEmbIdEntity rev3 = getAuditReader().find(SetRefEdEmbIdEntity.class, ed1_id, 3);
    assert rev1.getReffering().equals(makeSet(ing1, ing2));
    assert rev2.getReffering().equals(makeSet(ing2));
    assert rev3.getReffering().equals(Collections.EMPTY_SET);
}
Also used : SetRefIngEmbIdEntity(org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity) SetRefEdEmbIdEntity(org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity) Test(org.junit.Test)

Example 7 with SetRefEdEmbIdEntity

use of org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity in project hibernate-orm by hibernate.

the class EmbIdOneToManyQuery method initData.

@Test
@Priority(10)
public void initData() {
    id1 = new EmbId(0, 1);
    id2 = new EmbId(10, 11);
    id3 = new EmbId(20, 21);
    id4 = new EmbId(30, 31);
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    SetRefIngEmbIdEntity refIng1 = new SetRefIngEmbIdEntity(id1, "x", null);
    SetRefIngEmbIdEntity refIng2 = new SetRefIngEmbIdEntity(id2, "y", null);
    em.persist(refIng1);
    em.persist(refIng2);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    SetRefEdEmbIdEntity refEd3 = new SetRefEdEmbIdEntity(id3, "a");
    SetRefEdEmbIdEntity refEd4 = new SetRefEdEmbIdEntity(id4, "a");
    em.persist(refEd3);
    em.persist(refEd4);
    refIng1 = em.find(SetRefIngEmbIdEntity.class, id1);
    refIng2 = em.find(SetRefIngEmbIdEntity.class, id2);
    refIng1.setReference(refEd3);
    refIng2.setReference(refEd4);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    refEd3 = em.find(SetRefEdEmbIdEntity.class, id3);
    refIng2 = em.find(SetRefIngEmbIdEntity.class, id2);
    refIng2.setReference(refEd3);
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) SetRefIngEmbIdEntity(org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity) EmbId(org.hibernate.envers.test.entities.ids.EmbId) SetRefEdEmbIdEntity(org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

SetRefEdEmbIdEntity (org.hibernate.envers.test.entities.onetomany.ids.SetRefEdEmbIdEntity)7 SetRefIngEmbIdEntity (org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity)7 Test (org.junit.Test)7 EntityManager (javax.persistence.EntityManager)2 Priority (org.hibernate.envers.test.Priority)2 EmbId (org.hibernate.envers.test.entities.ids.EmbId)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1