use of org.hibernate.envers.test.entities.ids.EmbId in project hibernate-orm by hibernate.
the class BasicSetWithEmbId method initData.
@Test
@Priority(10)
public void initData() {
ed1_id = new EmbId(0, 1);
ed2_id = new EmbId(2, 3);
ing2_id = new EmbId(4, 5);
ing1_id = new EmbId(6, 7);
EntityManager em = getEntityManager();
SetRefEdEmbIdEntity ed1 = new SetRefEdEmbIdEntity(ed1_id, "data_ed_1");
SetRefEdEmbIdEntity ed2 = new SetRefEdEmbIdEntity(ed2_id, "data_ed_2");
SetRefIngEmbIdEntity ing1 = new SetRefIngEmbIdEntity(ing1_id, "data_ing_1", ed1);
SetRefIngEmbIdEntity ing2 = new SetRefIngEmbIdEntity(ing2_id, "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(SetRefIngEmbIdEntity.class, ing1.getId());
ed2 = em.find(SetRefEdEmbIdEntity.class, ed2.getId());
ing1.setReference(ed2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
ing2 = em.find(SetRefIngEmbIdEntity.class, ing2.getId());
ed2 = em.find(SetRefEdEmbIdEntity.class, ed2.getId());
ing2.setReference(ed2);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbId in project hibernate-orm by hibernate.
the class EmbIdSecondary method initData.
@Test
@Priority(10)
public void initData() {
id = new EmbId(1, 2);
SecondaryEmbIdTestEntity ste = new SecondaryEmbIdTestEntity(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(SecondaryEmbIdTestEntity.class, ste.getId());
ste.setS1("b");
ste.setS2("2");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbId 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.EmbId in project hibernate-orm by hibernate.
the class BasicDetachedSetWithEmbId method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
str1_id = new EmbId(1, 2);
str2_id = new EmbId(3, 4);
coll1_id = new EmbId(5, 6);
EmbIdTestEntity str1 = new EmbIdTestEntity(str1_id, "str1");
EmbIdTestEntity str2 = new EmbIdTestEntity(str2_id, "str2");
SetRefCollEntityEmbId coll1 = new SetRefCollEntityEmbId(coll1_id, "coll1");
// Revision 1
em.getTransaction().begin();
em.persist(str1);
em.persist(str2);
coll1.setCollection(new HashSet<EmbIdTestEntity>());
coll1.getCollection().add(str1);
em.persist(coll1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
str2 = em.find(EmbIdTestEntity.class, str2.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().add(str2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
str1 = em.find(EmbIdTestEntity.class, str1.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().remove(str1);
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().clear();
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.ids.EmbId in project hibernate-orm by hibernate.
the class UnidirectionalMulIdWithNulls method initData.
@Test
@Priority(10)
public void initData() {
ei = new EmbId(1, 2);
EntityManager em = getEntityManager();
// Revision 1
EmbIdTestEntity eite = new EmbIdTestEntity(ei, "data");
UniRefIngMulIdEntity notNullRef = new UniRefIngMulIdEntity(1, "data 1", eite);
UniRefIngMulIdEntity nullRef = new UniRefIngMulIdEntity(2, "data 2", null);
em.getTransaction().begin();
em.persist(eite);
em.persist(notNullRef);
em.persist(nullRef);
em.getTransaction().commit();
}
Aggregations