use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class JoinColumnBidirectionalList method createData.
@Test
@Priority(10)
public void createData() {
EntityManager em = getEntityManager();
ListJoinColumnBidirectionalRefEdEntity ed1 = new ListJoinColumnBidirectionalRefEdEntity("ed1", null);
ListJoinColumnBidirectionalRefEdEntity ed2 = new ListJoinColumnBidirectionalRefEdEntity("ed2", null);
ListJoinColumnBidirectionalRefIngEntity ing1 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed1);
ListJoinColumnBidirectionalRefIngEntity ing2 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed2);
// Revision 1 (ing1: ed1, ing2: ed2)
em.getTransaction().begin();
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.persist(ing2);
em.getTransaction().commit();
// Revision 2 (ing1: ed1, ed2)
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
ing2.getReferences().remove(ed2);
ing1.getReferences().add(ed2);
em.getTransaction().commit();
em.clear();
// No revision - no changes
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
ed2.setOwner(ing2);
em.getTransaction().commit();
em.clear();
// Revision 3 (ing1: ed1, ed2)
em.getTransaction().begin();
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed1.setData("ed1 bis");
// Shouldn't get written
ed1.setOwner(ing2);
em.getTransaction().commit();
em.clear();
// Revision 4 (ing2: ed1, ed2)
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ing1.getReferences().clear();
ing2.getReferences().add(ed1);
ing2.getReferences().add(ed2);
em.getTransaction().commit();
em.clear();
//
ing1_id = ing1.getId();
ing2_id = ing2.getId();
ed1_id = ed1.getId();
ed2_id = ed2.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class JoinColumnBidirectionalListWithInheritance method createData.
@Test
@Priority(10)
public void createData() {
EntityManager em = getEntityManager();
ListJoinColumnBidirectionalInheritanceRefEdParentEntity ed1 = new ListJoinColumnBidirectionalInheritanceRefEdChildEntity("ed1", null, "ed1 child");
ListJoinColumnBidirectionalInheritanceRefEdParentEntity ed2 = new ListJoinColumnBidirectionalInheritanceRefEdChildEntity("ed2", null, "ed2 child");
ListJoinColumnBidirectionalInheritanceRefIngEntity ing1 = new ListJoinColumnBidirectionalInheritanceRefIngEntity("coll1", ed1);
ListJoinColumnBidirectionalInheritanceRefIngEntity ing2 = new ListJoinColumnBidirectionalInheritanceRefIngEntity("coll1", ed2);
// Revision 1 (ing1: ed1, ing2: ed2)
em.getTransaction().begin();
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.persist(ing2);
em.getTransaction().commit();
// Revision 2 (ing1: ed1, ed2)
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalInheritanceRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalInheritanceRefIngEntity.class, ing2.getId());
ed1 = em.find(ListJoinColumnBidirectionalInheritanceRefEdParentEntity.class, ed1.getId());
ed2 = em.find(ListJoinColumnBidirectionalInheritanceRefEdParentEntity.class, ed2.getId());
ing2.getReferences().remove(ed2);
ing1.getReferences().add(ed2);
em.getTransaction().commit();
em.clear();
//
ing1_id = ing1.getId();
ing2_id = ing2.getId();
ed1_id = ed1.getId();
ed2_id = ed2.getId();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class CustomRevEntityQuery method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
StrIntTestEntity site2 = new StrIntTestEntity("b", 15);
em.persist(site1);
em.persist(site2);
id1 = site1.getId();
id2 = site2.getId();
em.getTransaction().commit();
Thread.sleep(100);
timestamp = System.currentTimeMillis();
Thread.sleep(100);
// Revision 2
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site1.setStr1("c");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class MaximalizePropertyQuery 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("b", 15);
StrIntTestEntity site3 = new StrIntTestEntity("c", 42);
StrIntTestEntity site4 = new StrIntTestEntity("d", 52);
em.persist(site1);
em.persist(site2);
em.persist(site3);
em.persist(site4);
id1 = site1.getId();
id2 = site2.getId();
id3 = site3.getId();
id4 = site4.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setStr1("d");
site2.setNumber(20);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setNumber(30);
site2.setStr1("z");
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setNumber(5);
site2.setStr1("a");
em.getTransaction().commit();
// Revision 5
em.getTransaction().begin();
site4 = em.find(StrIntTestEntity.class, id4);
em.remove(site4);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class InverseSideChanges method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");
SetRefIngEntity ing1 = new SetRefIngEntity(3, "data_ing_1");
// Revision 1
em.getTransaction().begin();
em.persist(ed1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ed1 = em.find(SetRefEdEntity.class, ed1.getId());
em.persist(ing1);
ed1.setReffering(new HashSet<SetRefIngEntity>());
ed1.getReffering().add(ing1);
em.getTransaction().commit();
//
ed1_id = ed1.getId();
ing1_id = ing1.getId();
}
Aggregations