use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class CompositeIds method testHistoryOfId1.
@Test
public void testHistoryOfId1() {
EmbIdTestEntity ver1 = new EmbIdTestEntity(id1, "x");
EmbIdTestEntity ver2 = new EmbIdTestEntity(id1, "x2");
assert getAuditReader().find(EmbIdTestEntity.class, id1, 1).equals(ver1);
assert getAuditReader().find(EmbIdTestEntity.class, id1, 2).equals(ver1);
assert getAuditReader().find(EmbIdTestEntity.class, id1, 3).equals(ver2);
assert getAuditReader().find(EmbIdTestEntity.class, id1, 4) == null;
assert getAuditReader().find(EmbIdTestEntity.class, id1, 5) == null;
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class CompositeIds method initData.
@Test
@Priority(10)
public void initData() {
id1 = new EmbId(1, 2);
id2 = new EmbId(10, 20);
id3 = new MulId(100, 101);
id4 = new MulId(102, 103);
id5 = new EmbIdWithCustomType(25, CustomEnum.NO);
id6 = new EmbIdWithCustomType(27, CustomEnum.YES);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(new EmbIdTestEntity(id1, "x"));
em.persist(new MulIdTestEntity(id3.getId1(), id3.getId2(), "a"));
em.persist(new EmbIdWithCustomTypeTestEntity(id5, "c"));
em.getTransaction().commit();
// Revision 2
em = getEntityManager();
em.getTransaction().begin();
em.persist(new EmbIdTestEntity(id2, "y"));
em.persist(new MulIdTestEntity(id4.getId1(), id4.getId2(), "b"));
em.persist(new EmbIdWithCustomTypeTestEntity(id6, "d"));
em.getTransaction().commit();
// Revision 3
em = getEntityManager();
em.getTransaction().begin();
EmbIdTestEntity ete1 = em.find(EmbIdTestEntity.class, id1);
EmbIdTestEntity ete2 = em.find(EmbIdTestEntity.class, id2);
MulIdTestEntity mte3 = em.find(MulIdTestEntity.class, id3);
MulIdTestEntity mte4 = em.find(MulIdTestEntity.class, id4);
EmbIdWithCustomTypeTestEntity cte5 = em.find(EmbIdWithCustomTypeTestEntity.class, id5);
EmbIdWithCustomTypeTestEntity cte6 = em.find(EmbIdWithCustomTypeTestEntity.class, id6);
ete1.setStr1("x2");
ete2.setStr1("y2");
mte3.setStr1("a2");
mte4.setStr1("b2");
cte5.setStr1("c2");
cte6.setStr1("d2");
em.getTransaction().commit();
// Revision 4
em = getEntityManager();
em.getTransaction().begin();
ete1 = em.find(EmbIdTestEntity.class, id1);
ete2 = em.find(EmbIdTestEntity.class, id2);
mte3 = em.find(MulIdTestEntity.class, id3);
cte5 = em.find(EmbIdWithCustomTypeTestEntity.class, id5);
cte6 = em.find(EmbIdWithCustomTypeTestEntity.class, id6);
em.remove(ete1);
em.remove(mte3);
em.remove(cte6);
ete2.setStr1("y3");
cte5.setStr1("c3");
em.getTransaction().commit();
// Revision 5
em = getEntityManager();
em.getTransaction().begin();
ete2 = em.find(EmbIdTestEntity.class, id2);
em.remove(ete2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class UnidirectionalMulIdWithNulls method testNotNullReference.
@Test
public void testNotNullReference() {
EmbIdTestEntity eite = getAuditReader().find(EmbIdTestEntity.class, ei, 1);
UniRefIngMulIdEntity notNullRef = getAuditReader().find(UniRefIngMulIdEntity.class, 1, 1);
assertNotNull(notNullRef.getReference());
assertEquals(notNullRef.getReference(), eite);
}
use of org.hibernate.envers.test.entities.ids.EmbIdTestEntity in project hibernate-orm by hibernate.
the class BasicDetachedSetWithEmbId method testHistoryOfColl1.
@Test
public void testHistoryOfColl1() {
EmbIdTestEntity str1 = getEntityManager().find(EmbIdTestEntity.class, str1_id);
EmbIdTestEntity str2 = getEntityManager().find(EmbIdTestEntity.class, str2_id);
SetRefCollEntityEmbId rev1 = getAuditReader().find(SetRefCollEntityEmbId.class, coll1_id, 1);
SetRefCollEntityEmbId rev2 = getAuditReader().find(SetRefCollEntityEmbId.class, coll1_id, 2);
SetRefCollEntityEmbId rev3 = getAuditReader().find(SetRefCollEntityEmbId.class, coll1_id, 3);
SetRefCollEntityEmbId rev4 = getAuditReader().find(SetRefCollEntityEmbId.class, coll1_id, 4);
assert rev1.getCollection().equals(TestTools.makeSet(str1));
assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
assert rev3.getCollection().equals(TestTools.makeSet(str2));
assert rev4.getCollection().equals(TestTools.makeSet());
assert "coll1".equals(rev1.getData());
assert "coll1".equals(rev2.getData());
assert "coll1".equals(rev3.getData());
assert "coll1".equals(rev4.getData());
}
Aggregations