use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class EntityNamesTest method initData.
@Test
@Priority(10)
public void initData() {
Person pers1 = new Person("Hernan", 28);
Person pers2 = new Person("Leandro", 29);
Person pers3 = new Person("Barba", 32);
Person pers4 = new Person("Camomo", 15);
// Revision 1
getSession().getTransaction().begin();
List<Person> owners = new ArrayList<Person>();
owners.add(pers1);
owners.add(pers2);
owners.add(pers3);
Car car1 = new Car(5, owners);
getSession().persist(car1);
getSession().getTransaction().commit();
long person1Id = pers1.getId();
// Revision 2
owners = new ArrayList<Person>();
owners.add(pers2);
owners.add(pers3);
owners.add(pers4);
Car car2 = new Car(27, owners);
getSession().getTransaction().begin();
Person person1 = (Person) getSession().get("Personaje", person1Id);
person1.setName("Hernan David");
person1.setAge(40);
getSession().persist(car1);
getSession().persist(car2);
getSession().getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class TrackingEntitiesMultipleChangesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste1 = new StrTestEntity("x");
StrTestEntity ste2 = new StrTestEntity("y");
em.persist(ste1);
em.persist(ste2);
steId1 = ste1.getId();
steId2 = ste2.getId();
em.getTransaction().commit();
// Revision 2 - Adding first and removing second entity
em.getTransaction().begin();
ste1 = em.find(StrTestEntity.class, steId1);
ste2 = em.find(StrTestEntity.class, steId2);
ste1.setStr("z");
em.remove(ste2);
em.getTransaction().commit();
// Revision 3 - Modifying and removing the same entity.
em.getTransaction().begin();
ste1 = em.find(StrTestEntity.class, steId1);
ste1.setStr("a");
em.merge(ste1);
em.remove(ste1);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class RevisionForDate method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
timestamp1 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity rfd = new StrTestEntity("x");
em.persist(rfd);
id = rfd.getId();
em.getTransaction().commit();
timestamp2 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 2
em.getTransaction().begin();
rfd = em.find(StrTestEntity.class, id);
rfd.setStr("y");
em.getTransaction().commit();
timestamp3 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 3
em.getTransaction().begin();
rfd = em.find(StrTestEntity.class, id);
rfd.setStr("z");
em.getTransaction().commit();
timestamp4 = System.currentTimeMillis();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class SameIds method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
SameIdTestEntity1 site1 = new SameIdTestEntity1(1, "str1");
SameIdTestEntity2 site2 = new SameIdTestEntity2(1, "str1");
em.persist(site1);
em.persist(site2);
em.getTransaction().commit();
em.getTransaction().begin();
site1 = em.find(SameIdTestEntity1.class, 1);
site2 = em.find(SameIdTestEntity2.class, 1);
site1.setStr1("str2");
site2.setStr1("str2");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class BasicSecondary method initData.
@Test
@Priority(10)
public void initData() {
SecondaryTestEntity ste = new SecondaryTestEntity("a", "1");
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
em.persist(ste);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ste = em.find(SecondaryTestEntity.class, ste.getId());
ste.setS1("b");
ste.setS2("2");
em.getTransaction().commit();
//
id = ste.getId();
}
Aggregations