use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity in project hibernate-orm by hibernate.
the class BasicSetWithMulId method testHistoryOfEdIng1.
@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);
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity in project hibernate-orm by hibernate.
the class MulIdOneToManyQuery method testEntitiesReferencedByIng2ToId3.
@Test
public void testEntitiesReferencedByIng2ToId3() {
List rev1_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getResultList();
List rev2_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getResultList();
Object rev3_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getSingleResult();
assertEquals(0, rev1_related.size());
assertEquals(0, rev2_related.size());
assertEquals(new SetRefIngMulIdEntity(id2, "y", null), rev3_related);
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity in project hibernate-orm by hibernate.
the class MulIdOneToManyQuery method initData.
@Test
@Priority(10)
public void initData() {
id1 = new MulId(0, 1);
id2 = new MulId(10, 11);
id3 = new MulId(20, 21);
id4 = new MulId(30, 31);
// 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();
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity in project hibernate-orm by hibernate.
the class MulIdOneToManyQuery method testEntitiesReferencedToId3.
@Test
public void testEntitiesReferencedToId3() {
Set rev1_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev1 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1).add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null))).getResultList());
Set rev2_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev2 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2).add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null))).getResultList());
Set rev3_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev3 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3).add(AuditEntity.property("reference").eq(new SetRefEdMulIdEntity(id3, null))).getResultList());
assertEquals(rev1, rev1_related);
assertEquals(rev2, rev2_related);
assertEquals(rev3, rev3_related);
assertEquals(rev1, TestTools.makeSet());
assertEquals(rev2, TestTools.makeSet(new SetRefIngMulIdEntity(id1, "x", null)));
assertEquals(rev3, TestTools.makeSet(new SetRefIngMulIdEntity(id1, "x", null), new SetRefIngMulIdEntity(id2, "y", null)));
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngMulIdEntity in project hibernate-orm by hibernate.
the class MulIdOneToManyQuery method testEntitiesReferencedByIng1ToId3.
@Test
public void testEntitiesReferencedByIng1ToId3() {
List rev1_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 1).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id1)).getResultList();
Object rev2_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 2).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id1)).getSingleResult();
Object rev3_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngMulIdEntity.class, 3).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id1)).getSingleResult();
assertEquals(0, rev1_related.size());
assertEquals(rev2_related, new SetRefIngMulIdEntity(id1, "x", null));
assertEquals(rev3_related, new SetRefIngMulIdEntity(id1, "x", null));
}
Aggregations