use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.
the class BasicCollection method testHistoryOfEdIng2.
@Test
public void testHistoryOfEdIng2() {
CollectionRefEdEntity ed1 = getEntityManager().find(CollectionRefEdEntity.class, ed1_id);
CollectionRefEdEntity ed2 = getEntityManager().find(CollectionRefEdEntity.class, ed2_id);
CollectionRefIngEntity rev1 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 1);
CollectionRefIngEntity rev2 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 2);
CollectionRefIngEntity rev3 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 3);
assert rev1.getReference().equals(ed1);
assert rev2.getReference().equals(ed1);
assert rev3.getReference().equals(ed2);
}
use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.
the class BasicCollection method testHistoryOfEdIng1.
@Test
public void testHistoryOfEdIng1() {
CollectionRefEdEntity ed1 = getEntityManager().find(CollectionRefEdEntity.class, ed1_id);
CollectionRefEdEntity ed2 = getEntityManager().find(CollectionRefEdEntity.class, ed2_id);
CollectionRefIngEntity rev1 = getAuditReader().find(CollectionRefIngEntity.class, ing1_id, 1);
CollectionRefIngEntity rev2 = getAuditReader().find(CollectionRefIngEntity.class, ing1_id, 2);
CollectionRefIngEntity rev3 = getAuditReader().find(CollectionRefIngEntity.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.CollectionRefEdEntity in project hibernate-orm by hibernate.
the class BasicCollection method testHistoryOfEdId1.
@Test
public void testHistoryOfEdId1() {
CollectionRefIngEntity ing1 = getEntityManager().find(CollectionRefIngEntity.class, ing1_id);
CollectionRefIngEntity ing2 = getEntityManager().find(CollectionRefIngEntity.class, ing2_id);
CollectionRefEdEntity rev1 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 1);
CollectionRefEdEntity rev2 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 2);
CollectionRefEdEntity rev3 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 3);
assert rev1.getReffering().containsAll(makeSet(ing1, ing2));
assert rev1.getReffering().size() == 2;
assert rev2.getReffering().containsAll(makeSet(ing2));
assert rev2.getReffering().size() == 1;
assert rev3.getReffering().containsAll(Collections.EMPTY_SET);
assert rev3.getReffering().size() == 0;
}
use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.
the class SerializingCollection method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
CollectionRefEdEntity ed1 = new CollectionRefEdEntity(1, "data_ed_1");
CollectionRefIngEntity ing1 = new CollectionRefIngEntity(3, "data_ing_1", ed1);
// Revision 1
em.getTransaction().begin();
em.persist(ed1);
em.persist(ing1);
em.getTransaction().commit();
//
ed1_id = ed1.getId();
ing1_id = ing1.getId();
}
use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.
the class SerializingCollection method testDetach.
@Test
public void testDetach() throws Exception {
CollectionRefIngEntity ing1 = getEntityManager().find(CollectionRefIngEntity.class, ing1_id);
CollectionRefEdEntity rev1 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 1);
// First forcing loading of the collection
assert rev1.getReffering().size() == 1;
// Now serializing and de-serializing the
rev1 = serializeDeserialize(rev1);
// And checking the colleciton again
assert rev1.getReffering().contains(ing1);
assert rev1.getReffering().size() == 1;
}
Aggregations