Search in sources :

Example 1 with Person

use of org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person in project hibernate-orm by hibernate.

the class HasChangedAuditedManyToManyTest method initData.

@Test
@Priority(10)
public void initData() {
    initializeSession();
    Person pers1 = new Person("Hernan", 28);
    Person pers2 = new Person("Leandro", 29);
    Person pers3 = new Person("Barba", 32);
    Person pers4 = new Person("Camomo", 15);
    //REV 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();
    id_pers1 = pers1.getId();
    id_car1 = car1.getId();
    id_pers2 = pers2.getId();
    owners = new ArrayList<Person>();
    owners.add(pers2);
    owners.add(pers3);
    owners.add(pers4);
    Car car2 = new Car(27, owners);
    //REV 2
    getSession().getTransaction().begin();
    Person person1 = (Person) getSession().get("Personaje", id_pers1);
    person1.setName("Hernan David");
    person1.setAge(40);
    getSession().persist(car1);
    getSession().persist(car2);
    getSession().getTransaction().commit();
}
Also used : Car(org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Car) ArrayList(java.util.ArrayList) Person(org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 2 with Person

use of org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person 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();
}
Also used : Car(org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Car) ArrayList(java.util.ArrayList) Person(org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

ArrayList (java.util.ArrayList)2 Priority (org.hibernate.envers.test.Priority)2 Car (org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Car)2 Person (org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person)2 Test (org.junit.Test)2