use of org.hibernate.envers.test.entities.onetomany.ListRefEdEntity in project hibernate-orm by hibernate.
the class BasicList method testHistoryOfEdId1.
@Test
public void testHistoryOfEdId1() {
ListRefIngEntity ing1 = getEntityManager().find(ListRefIngEntity.class, ing1_id);
ListRefIngEntity ing2 = getEntityManager().find(ListRefIngEntity.class, ing2_id);
ListRefEdEntity rev1 = getAuditReader().find(ListRefEdEntity.class, ed1_id, 1);
ListRefEdEntity rev2 = getAuditReader().find(ListRefEdEntity.class, ed1_id, 2);
ListRefEdEntity rev3 = getAuditReader().find(ListRefEdEntity.class, ed1_id, 3);
assert TestTools.checkCollection(rev1.getReffering(), ing1, ing2);
assert TestTools.checkCollection(rev2.getReffering(), ing2);
assert TestTools.checkCollection(rev3.getReffering());
}
use of org.hibernate.envers.test.entities.onetomany.ListRefEdEntity in project hibernate-orm by hibernate.
the class BasicList method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
ListRefEdEntity ed1 = new ListRefEdEntity(1, "data_ed_1");
ListRefEdEntity ed2 = new ListRefEdEntity(2, "data_ed_2");
ListRefIngEntity ing1 = new ListRefIngEntity(3, "data_ing_1", ed1);
ListRefIngEntity ing2 = new ListRefIngEntity(4, "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(ListRefIngEntity.class, ing1.getId());
ed2 = em.find(ListRefEdEntity.class, ed2.getId());
ing1.setReference(ed2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
ing2 = em.find(ListRefIngEntity.class, ing2.getId());
ed2 = em.find(ListRefEdEntity.class, ed2.getId());
ing2.setReference(ed2);
em.getTransaction().commit();
//
ed1_id = ed1.getId();
ed2_id = ed2.getId();
ing1_id = ing1.getId();
ing2_id = ing2.getId();
}
use of org.hibernate.envers.test.entities.onetomany.ListRefEdEntity in project hibernate-orm by hibernate.
the class BasicList method testHistoryOfEdId2.
@Test
public void testHistoryOfEdId2() {
ListRefIngEntity ing1 = getEntityManager().find(ListRefIngEntity.class, ing1_id);
ListRefIngEntity ing2 = getEntityManager().find(ListRefIngEntity.class, ing2_id);
ListRefEdEntity rev1 = getAuditReader().find(ListRefEdEntity.class, ed2_id, 1);
ListRefEdEntity rev2 = getAuditReader().find(ListRefEdEntity.class, ed2_id, 2);
ListRefEdEntity rev3 = getAuditReader().find(ListRefEdEntity.class, ed2_id, 3);
assert TestTools.checkCollection(rev1.getReffering());
assert TestTools.checkCollection(rev2.getReffering(), ing1);
assert TestTools.checkCollection(rev3.getReffering(), ing1, ing2);
}
use of org.hibernate.envers.test.entities.onetomany.ListRefEdEntity in project hibernate-orm by hibernate.
the class AuditedCollectionProxyTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
ListRefEdEntity listReferencedEntity1 = new ListRefEdEntity(Integer.valueOf(1), "str1");
ListRefIngEntity refingEntity1 = new ListRefIngEntity(Integer.valueOf(1), "refing1", listReferencedEntity1);
// Revision 1
em.getTransaction().begin();
em.persist(listReferencedEntity1);
em.persist(refingEntity1);
em.getTransaction().commit();
id_ListRefEdEntity1 = listReferencedEntity1.getId();
// Revision 2
ListRefIngEntity refingEntity2 = new ListRefIngEntity(Integer.valueOf(2), "refing2", listReferencedEntity1);
em.getTransaction().begin();
em.persist(refingEntity2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.onetomany.ListRefEdEntity in project hibernate-orm by hibernate.
the class AuditedCollectionProxyTest method testProxyIdentifier.
@Test
public void testProxyIdentifier() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
ListRefEdEntity listReferencedEntity1 = em.getReference(ListRefEdEntity.class, id_ListRefEdEntity1);
assert listReferencedEntity1 instanceof HibernateProxy;
// Revision 3
ListRefIngEntity refingEntity3 = new ListRefIngEntity(Integer.valueOf(3), "refing3", listReferencedEntity1);
em.persist(refingEntity3);
listReferencedEntity1.getReffering().size();
em.getTransaction().commit();
}
Aggregations