use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity in project hibernate-orm by hibernate.
the class BasicSetWithEmbId method initData.
@Test
@Priority(10)
public void initData() {
ed1_id = new EmbId(0, 1);
ed2_id = new EmbId(2, 3);
ing2_id = new EmbId(4, 5);
ing1_id = new EmbId(6, 7);
EntityManager em = getEntityManager();
SetRefEdEmbIdEntity ed1 = new SetRefEdEmbIdEntity(ed1_id, "data_ed_1");
SetRefEdEmbIdEntity ed2 = new SetRefEdEmbIdEntity(ed2_id, "data_ed_2");
SetRefIngEmbIdEntity ing1 = new SetRefIngEmbIdEntity(ing1_id, "data_ing_1", ed1);
SetRefIngEmbIdEntity ing2 = new SetRefIngEmbIdEntity(ing2_id, "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(SetRefIngEmbIdEntity.class, ing1.getId());
ed2 = em.find(SetRefEdEmbIdEntity.class, ed2.getId());
ing1.setReference(ed2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
ing2 = em.find(SetRefIngEmbIdEntity.class, ing2.getId());
ed2 = em.find(SetRefEdEmbIdEntity.class, ed2.getId());
ing2.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity in project hibernate-orm by hibernate.
the class EmbIdOneToManyQuery method testEntitiesReferencedToId3.
@Test
public void testEntitiesReferencedToId3() {
Set rev1_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev1 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1).add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null))).getResultList());
Set rev2_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev2 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2).add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null))).getResultList());
Set rev3_related = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3).add(AuditEntity.relatedId("reference").eq(id3)).getResultList());
Set rev3 = new HashSet(getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3).add(AuditEntity.property("reference").eq(new SetRefEdEmbIdEntity(id3, null))).getResultList());
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 SetRefIngEmbIdEntity(id1, "x", null)));
assert rev3.equals(TestTools.makeSet(new SetRefIngEmbIdEntity(id1, "x", null), new SetRefIngEmbIdEntity(id2, "y", null)));
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity in project hibernate-orm by hibernate.
the class EmbIdOneToManyQuery method testEntitiesReferencedByIng2ToId3.
@Test
public void testEntitiesReferencedByIng2ToId3() {
List rev1_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 1).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getResultList();
List rev2_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 2).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getResultList();
Object rev3_related = getAuditReader().createQuery().forEntitiesAtRevision(SetRefIngEmbIdEntity.class, 3).add(AuditEntity.relatedId("reference").eq(id3)).add(AuditEntity.id().eq(id2)).getSingleResult();
assert rev1_related.size() == 0;
assert rev2_related.size() == 0;
assert rev3_related.equals(new SetRefIngEmbIdEntity(id2, "y", null));
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity in project hibernate-orm by hibernate.
the class NullPropertyQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity nullSite = new StrIntTestEntity(null, 1);
StrIntTestEntity notNullSite = new StrIntTestEntity("data", 2);
em.persist(nullSite);
em.persist(notNullSite);
idSimplePropertyNull = nullSite.getId();
idSimplePropertyNotNull = notNullSite.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
SetRefIngEmbIdEntity nullParentSrieie = new SetRefIngEmbIdEntity(idMulticolumnReferenceToParentNull, "data", null);
em.persist(nullParentSrieie);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
CollectionRefEdEntity parent = new CollectionRefEdEntity(idParent, "data");
CollectionRefIngEntity notNullParentCrie = new CollectionRefIngEntity(idReferenceToParentNotNull, "data", parent);
em.persist(parent);
em.persist(notNullParentCrie);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity in project hibernate-orm by hibernate.
the class BasicSetWithEmbId method testHistoryOfEdIng2.
@Test
public void testHistoryOfEdIng2() {
SetRefEdEmbIdEntity ed1 = getEntityManager().find(SetRefEdEmbIdEntity.class, ed1_id);
SetRefEdEmbIdEntity ed2 = getEntityManager().find(SetRefEdEmbIdEntity.class, ed2_id);
SetRefIngEmbIdEntity rev1 = getAuditReader().find(SetRefIngEmbIdEntity.class, ing2_id, 1);
SetRefIngEmbIdEntity rev2 = getAuditReader().find(SetRefIngEmbIdEntity.class, ing2_id, 2);
SetRefIngEmbIdEntity rev3 = getAuditReader().find(SetRefIngEmbIdEntity.class, ing2_id, 3);
assert rev1.getReference().equals(ed1);
assert rev2.getReference().equals(ed1);
assert rev3.getReference().equals(ed2);
}
Aggregations