use of org.hibernate.envers.test.entities.onetomany.SetRefEdEntity in project hibernate-orm by hibernate.
the class OneToManyCache method testCacheReferenceAccessAfterFind.
@Test
public void testCacheReferenceAccessAfterFind() {
SetRefEdEntity ed1_rev1 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 1);
SetRefIngEntity ing1_rev1 = getAuditReader().find(SetRefIngEntity.class, ing1_id, 1);
SetRefIngEntity ing2_rev1 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 1);
// It should be exactly the same object
assert ing1_rev1.getReference() == ed1_rev1;
assert ing2_rev1.getReference() == ed1_rev1;
}
use of org.hibernate.envers.test.entities.onetomany.SetRefEdEntity in project hibernate-orm by hibernate.
the class OneToManyCache method testCacheFindAfterCollectionAccessRev1.
@Test
public void testCacheFindAfterCollectionAccessRev1() {
SetRefEdEntity ed1_rev1 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 1);
// Reading the collection
assert ed1_rev1.getReffering().size() == 2;
SetRefIngEntity ing1_rev1 = getAuditReader().find(SetRefIngEntity.class, ing1_id, 1);
SetRefIngEntity ing2_rev1 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 1);
for (SetRefIngEntity setRefIngEntity : ed1_rev1.getReffering()) {
assert setRefIngEntity == ing1_rev1 || setRefIngEntity == ing2_rev1;
}
}
use of org.hibernate.envers.test.entities.onetomany.SetRefEdEntity in project hibernate-orm by hibernate.
the class BasicSet method testHistoryOfEdId1.
@Test
public void testHistoryOfEdId1() {
SetRefIngEntity ing1 = getEntityManager().find(SetRefIngEntity.class, ing1_id);
SetRefIngEntity ing2 = getEntityManager().find(SetRefIngEntity.class, ing2_id);
SetRefEdEntity rev1 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 1);
SetRefEdEntity rev2 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 2);
SetRefEdEntity rev3 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 3);
SetRefEdEntity rev4 = getAuditReader().find(SetRefEdEntity.class, ed1_id, 4);
assert rev1.getReffering().equals(Collections.EMPTY_SET);
assert rev2.getReffering().equals(TestTools.makeSet(ing1, ing2));
assert rev3.getReffering().equals(TestTools.makeSet(ing2));
assert rev4.getReffering().equals(Collections.EMPTY_SET);
}
use of org.hibernate.envers.test.entities.onetomany.SetRefEdEntity in project hibernate-orm by hibernate.
the class BasicSet method testHistoryOfEdIng2.
@Test
public void testHistoryOfEdIng2() {
SetRefEdEntity ed1 = getEntityManager().find(SetRefEdEntity.class, ed1_id);
SetRefEdEntity ed2 = getEntityManager().find(SetRefEdEntity.class, ed2_id);
SetRefIngEntity rev1 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 1);
SetRefIngEntity rev2 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 2);
SetRefIngEntity rev3 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 3);
SetRefIngEntity rev4 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 4);
assert rev1 == null;
assert rev2.getReference().equals(ed1);
assert rev3.getReference().equals(ed1);
assert rev4.getReference().equals(ed2);
}
use of org.hibernate.envers.test.entities.onetomany.SetRefEdEntity in project hibernate-orm by hibernate.
the class BasicSetWithNullsDelete method testHistoryOfEdIng2.
@Test
public void testHistoryOfEdIng2() {
SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");
SetRefIngEntity rev1 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 1);
SetRefIngEntity rev2 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 2);
SetRefIngEntity rev3 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 3);
SetRefIngEntity rev4 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 4);
SetRefIngEntity rev5 = getAuditReader().find(SetRefIngEntity.class, ing2_id, 5);
assert rev1.getReference().equals(ed1);
assert rev2.getReference().equals(ed1);
assert rev3 == null;
assert rev4 == null;
assert rev5 == null;
}
Aggregations