use of org.hibernate.envers.test.entities.ids.EmbId 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.EmbId in project hibernate-orm by hibernate.
the class EmbIdBidirectional method initData.
@Test
@Priority(10)
public void initData() {
ed1_id = new EmbId(1, 2);
ed2_id = new EmbId(3, 4);
ing1_id = new EmbId(5, 6);
BiEmbIdRefEdEntity ed1 = new BiEmbIdRefEdEntity(ed1_id, "data_ed_1");
BiEmbIdRefEdEntity ed2 = new BiEmbIdRefEdEntity(ed2_id, "data_ed_2");
BiEmbIdRefIngEntity ing1 = new BiEmbIdRefIngEntity(ing1_id, "data_ing_1");
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
ing1.setReference(ed1);
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ing1 = em.find(BiEmbIdRefIngEntity.class, ing1.getId());
ed2 = em.find(BiEmbIdRefEdEntity.class, ed2.getId());
ing1.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbId in project hibernate-orm by hibernate.
the class EmbIdOneToManyQuery method initData.
@Test
@Priority(10)
public void initData() {
id1 = new EmbId(0, 1);
id2 = new EmbId(10, 11);
id3 = new EmbId(20, 21);
id4 = new EmbId(30, 31);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
SetRefIngEmbIdEntity refIng1 = new SetRefIngEmbIdEntity(id1, "x", null);
SetRefIngEmbIdEntity refIng2 = new SetRefIngEmbIdEntity(id2, "y", null);
em.persist(refIng1);
em.persist(refIng2);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
SetRefEdEmbIdEntity refEd3 = new SetRefEdEmbIdEntity(id3, "a");
SetRefEdEmbIdEntity refEd4 = new SetRefEdEmbIdEntity(id4, "a");
em.persist(refEd3);
em.persist(refEd4);
refIng1 = em.find(SetRefIngEmbIdEntity.class, id1);
refIng2 = em.find(SetRefIngEmbIdEntity.class, id2);
refIng1.setReference(refEd3);
refIng2.setReference(refEd4);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
refEd3 = em.find(SetRefEdEmbIdEntity.class, id3);
refIng2 = em.find(SetRefIngEmbIdEntity.class, id2);
refIng2.setReference(refEd3);
em.getTransaction().commit();
}
Aggregations