Search in sources :

Example 56 with Priority

use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.

the class HasChangedNotOwnedBidirectional method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    pc_id = 1l;
    a1_id = 10l;
    a2_id = 100l;
    // Rev 1
    em.getTransaction().begin();
    PersonalContact pc = new PersonalContact(pc_id, "e", "f");
    Address a1 = new Address(a1_id, "a1");
    a1.setContact(pc);
    em.persist(pc);
    em.persist(a1);
    em.getTransaction().commit();
    // Rev 2
    em.getTransaction().begin();
    pc = em.find(PersonalContact.class, pc_id);
    Address a2 = new Address(a2_id, "a2");
    a2.setContact(pc);
    em.persist(a2);
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Address(org.hibernate.envers.test.integration.inheritance.joined.notownedrelation.Address) PersonalContact(org.hibernate.envers.test.integration.inheritance.joined.notownedrelation.PersonalContact) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 57 with Priority

use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.

the class MultipleAssociationsTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    Person lukasz = new Person("Lukasz");
    Person kinga = new Person("Kinga");
    Address warsaw = new Address("Warsaw");
    warsaw.getTenants().add(lukasz);
    warsaw.setLandlord(lukasz);
    warsaw.getTenants().add(kinga);
    lukasz.getAddresses().add(warsaw);
    lukasz.getOwnedAddresses().add(warsaw);
    kinga.getAddresses().add(warsaw);
    em.persist(lukasz);
    em.persist(kinga);
    em.persist(warsaw);
    em.getTransaction().commit();
    lukaszId = lukasz.getId();
    kingaId = kinga.getId();
    warsawId = warsaw.getId();
    // Revision 2
    em.getTransaction().begin();
    kinga = em.find(Person.class, kinga.getId());
    Address cracow = new Address("Cracow");
    kinga.getAddresses().add(cracow);
    cracow.getTenants().add(kinga);
    cracow.setLandlord(kinga);
    em.persist(cracow);
    em.getTransaction().commit();
    cracowId = cracow.getId();
    // Revision 3
    em.getTransaction().begin();
    cracow = em.find(Address.class, cracow.getId());
    cracow.setCity("Krakow");
    em.merge(cracow);
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    lukasz = em.find(Person.class, lukasz.getId());
    lukasz.setName("Lucas");
    em.merge(lukasz);
    em.getTransaction().commit();
    // Revision 5
    em.getTransaction().begin();
    warsaw = em.find(Address.class, warsaw.getId());
    lukasz = em.find(Person.class, lukasz.getId());
    kinga = em.find(Person.class, kinga.getId());
    warsaw.setLandlord(kinga);
    kinga.getOwnedAddresses().add(warsaw);
    lukasz.getOwnedAddresses().remove(warsaw);
    em.merge(warsaw);
    em.merge(lukasz);
    em.merge(kinga);
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 58 with Priority

use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.

the class AuditColumnNameTest method initData.

@Test
@Priority(10)
public void initData() {
    NamingTestEntity2 nte1 = new NamingTestEntity2("data1");
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    em.persist(nte1);
    em.getTransaction().commit();
    this.id = nte1.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 59 with Priority

use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.

the class EstonianTableAlias method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    Parent parent = new Parent("parent");
    Child child = new Child("child");
    parent.getCollection().add(child);
    em.persist(child);
    em.persist(parent);
    em.getTransaction().commit();
    parentId = parent.getId();
    childId = child.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) Parent(ee.estonia.entities.Parent) Child(ee.estonia.entities.Child) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 60 with Priority

use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.

the class OneToManyUnidirectionalNaming method initData.

@Test
@Priority(10)
public void initData() {
    DetachedNamingTestEntity uni1 = new DetachedNamingTestEntity(1, "data1");
    StrTestEntity str1 = new StrTestEntity("str1");
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    uni1.setCollection(new HashSet<StrTestEntity>());
    em.persist(uni1);
    em.persist(str1);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    uni1 = em.find(DetachedNamingTestEntity.class, uni1.getId());
    str1 = em.find(StrTestEntity.class, str1.getId());
    uni1.getCollection().add(str1);
    em.getTransaction().commit();
    //
    uni1_id = uni1.getId();
    str1_id = str1.getId();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

Priority (org.hibernate.envers.test.Priority)268 Test (org.junit.Test)268 EntityManager (javax.persistence.EntityManager)249 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)48 Session (org.hibernate.Session)16 StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)12 EmbId (org.hibernate.envers.test.entities.ids.EmbId)8 UnversionedStrTestEntity (org.hibernate.envers.test.entities.UnversionedStrTestEntity)7 Component1 (org.hibernate.envers.test.entities.components.Component1)7 MulId (org.hibernate.envers.test.entities.ids.MulId)7 HashSet (java.util.HashSet)6 IntTestEntity (org.hibernate.envers.test.entities.IntTestEntity)6 SetRefEdEntity (org.hibernate.envers.test.entities.onetomany.SetRefEdEntity)6 SetRefIngEntity (org.hibernate.envers.test.entities.onetomany.SetRefIngEntity)6 Component2 (org.hibernate.envers.test.entities.components.Component2)5 ComponentTestEntity (org.hibernate.envers.test.entities.components.ComponentTestEntity)4 CollectionRefEdEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity)4 CollectionRefIngEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3