use of org.hibernate.envers.test.entities.ids.MulId in project hibernate-orm by hibernate.
the class MulIdSecondary method initData.
@Test
@Priority(10)
public void initData() {
id = new MulId(1, 2);
SecondaryMulIdTestEntity ste = new SecondaryMulIdTestEntity(id, "a", "1");
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(ste);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ste = em.find(SecondaryMulIdTestEntity.class, id);
ste.setS1("b");
ste.setS2("2");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.MulId in project hibernate-orm by hibernate.
the class SimpleQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
StrIntTestEntity site2 = new StrIntTestEntity("a", 10);
StrIntTestEntity site3 = new StrIntTestEntity("b", 5);
em.persist(site1);
em.persist(site2);
em.persist(site3);
id1 = site1.getId();
id2 = site2.getId();
id3 = site3.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
mulId1 = new MulId(1, 2);
em.persist(new MulIdTestEntity(mulId1.getId1(), mulId1.getId2(), "data"));
embId1 = new EmbId(3, 4);
em.persist(new EmbIdTestEntity(embId1, "something"));
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setStr1("aBc");
site2.setNumber(20);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
site3 = em.find(StrIntTestEntity.class, id3);
site3.setStr1("a");
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
em.remove(site1);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.MulId in project hibernate-orm by hibernate.
the class MulIdBidirectional method initData.
@Test
@Priority(10)
public void initData() {
ed1_id = new MulId(1, 2);
ed2_id = new MulId(3, 4);
ing1_id = new MulId(5, 6);
BiMulIdRefEdEntity ed1 = new BiMulIdRefEdEntity(ed1_id.getId1(), ed1_id.getId2(), "data_ed_1");
BiMulIdRefEdEntity ed2 = new BiMulIdRefEdEntity(ed2_id.getId1(), ed2_id.getId2(), "data_ed_2");
BiMulIdRefIngEntity ing1 = new BiMulIdRefIngEntity(ing1_id.getId1(), ing1_id.getId2(), "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(BiMulIdRefIngEntity.class, ing1_id);
ed2 = em.find(BiMulIdRefEdEntity.class, ed2_id);
ing1.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.MulId in project hibernate-orm by hibernate.
the class BasicSetWithMulId method initData.
@Test
@Priority(10)
public void initData() {
ed1_id = new MulId(0, 1);
ed2_id = new MulId(2, 3);
ing2_id = new MulId(4, 5);
ing1_id = new MulId(6, 7);
EntityManager em = getEntityManager();
SetRefEdMulIdEntity ed1 = new SetRefEdMulIdEntity(ed1_id.getId1(), ed1_id.getId2(), "data_ed_1");
SetRefEdMulIdEntity ed2 = new SetRefEdMulIdEntity(ed2_id.getId1(), ed2_id.getId2(), "data_ed_2");
SetRefIngMulIdEntity ing1 = new SetRefIngMulIdEntity(ing1_id.getId1(), ing1_id.getId2(), "data_ing_1", ed1);
SetRefIngMulIdEntity ing2 = new SetRefIngMulIdEntity(ing2_id.getId1(), ing2_id.getId2(), "data_ing_2", ed1);
// Revision 1
em.getTransaction().begin();
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.persist(ing2);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ing1 = em.find(SetRefIngMulIdEntity.class, ing1_id);
ed2 = em.find(SetRefEdMulIdEntity.class, ed2_id);
ing1.setReference(ed2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
ing2 = em.find(SetRefIngMulIdEntity.class, ing2_id);
ed2 = em.find(SetRefEdMulIdEntity.class, ed2_id);
ing2.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.MulId 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();
}
Aggregations