use of org.hibernate.envers.test.entities.manytomany.ListOwnedEntity in project hibernate-orm by hibernate.
the class BasicList method testHistoryOfEdIng1.
@Test
public void testHistoryOfEdIng1() {
ListOwnedEntity ed1 = getEntityManager().find(ListOwnedEntity.class, ed1_id);
ListOwnedEntity ed2 = getEntityManager().find(ListOwnedEntity.class, ed2_id);
ListOwningEntity rev1 = getAuditReader().find(ListOwningEntity.class, ing1_id, 1);
ListOwningEntity rev2 = getAuditReader().find(ListOwningEntity.class, ing1_id, 2);
ListOwningEntity rev3 = getAuditReader().find(ListOwningEntity.class, ing1_id, 3);
ListOwningEntity rev4 = getAuditReader().find(ListOwningEntity.class, ing1_id, 4);
ListOwningEntity rev5 = getAuditReader().find(ListOwningEntity.class, ing1_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_LIST);
assert TestTools.checkCollection(rev2.getReferences(), ed1);
assert TestTools.checkCollection(rev3.getReferences(), ed1, ed2);
assert TestTools.checkCollection(rev4.getReferences(), ed2);
assert rev5.getReferences().equals(Collections.EMPTY_LIST);
}
use of org.hibernate.envers.test.entities.manytomany.ListOwnedEntity in project hibernate-orm by hibernate.
the class BasicList method testHistoryOfEdIng2.
@Test
public void testHistoryOfEdIng2() {
ListOwnedEntity ed1 = getEntityManager().find(ListOwnedEntity.class, ed1_id);
ListOwnedEntity ed2 = getEntityManager().find(ListOwnedEntity.class, ed2_id);
ListOwningEntity rev1 = getAuditReader().find(ListOwningEntity.class, ing2_id, 1);
ListOwningEntity rev2 = getAuditReader().find(ListOwningEntity.class, ing2_id, 2);
ListOwningEntity rev3 = getAuditReader().find(ListOwningEntity.class, ing2_id, 3);
ListOwningEntity rev4 = getAuditReader().find(ListOwningEntity.class, ing2_id, 4);
ListOwningEntity rev5 = getAuditReader().find(ListOwningEntity.class, ing2_id, 5);
assert rev1.getReferences().equals(Collections.EMPTY_LIST);
assert TestTools.checkCollection(rev2.getReferences(), ed1, ed2);
assert TestTools.checkCollection(rev3.getReferences(), ed1, ed2);
assert TestTools.checkCollection(rev4.getReferences(), ed1, ed2);
assert TestTools.checkCollection(rev5.getReferences(), ed1, ed2);
}
use of org.hibernate.envers.test.entities.manytomany.ListOwnedEntity in project hibernate-orm by hibernate.
the class AbstractRevisionEntityRemovalTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - simple entity
em.getTransaction().begin();
em.persist(new StrTestEntity("data"));
em.getTransaction().commit();
// Revision 2 - many-to-many relation
em.getTransaction().begin();
ListOwnedEntity owned = new ListOwnedEntity(1, "data");
ListOwningEntity owning = new ListOwningEntity(1, "data");
owned.setReferencing(new ArrayList<ListOwningEntity>());
owning.setReferences(new ArrayList<ListOwnedEntity>());
owned.getReferencing().add(owning);
owning.getReferences().add(owned);
em.persist(owned);
em.persist(owning);
em.getTransaction().commit();
em.getTransaction().begin();
Assert.assertEquals(1, countRecords(em, "STR_TEST_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwned_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwning_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwning_ListOwned_AUD"));
em.getTransaction().commit();
em.close();
}
Aggregations