Search in sources :

Example 1 with Priority

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

the class EmptyStringTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    StrTestEntity emptyEntity = new StrTestEntity("");
    em.persist(emptyEntity);
    StrTestEntity nullEntity = new StrTestEntity(null);
    em.persist(nullEntity);
    em.getTransaction().commit();
    emptyId = emptyEntity.getId();
    nullId = nullEntity.getId();
    em.close();
    em = getEntityManager();
    // Should not generate revision afterQuery NULL to "" modification and vice versa on Oracle.
    em.getTransaction().begin();
    emptyEntity = em.find(StrTestEntity.class, emptyId);
    emptyEntity.setStr(null);
    em.merge(emptyEntity);
    nullEntity = em.find(StrTestEntity.class, nullId);
    nullEntity.setStr("");
    em.merge(nullEntity);
    em.getTransaction().commit();
    em.close();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 2 with Priority

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

the class GlobalVersioned method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    BasicTestEntity4 bte1 = new BasicTestEntity4("x", "y");
    em.persist(bte1);
    id1 = bte1.getId();
    em.getTransaction().commit();
    em.getTransaction().begin();
    bte1 = em.find(BasicTestEntity4.class, id1);
    bte1.setStr1("a");
    bte1.setStr2("b");
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 3 with Priority

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

the class ImmutableClassAccessType method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    country = Country.of(123, "Germany");
    em.persist(country);
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 4 with Priority

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

the class PropertyAccessType method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    PropertyAccessTypeEntity pate = new PropertyAccessTypeEntity("data");
    em.persist(pate);
    id1 = pate.getId();
    em.getTransaction().commit();
    em.getTransaction().begin();
    pate = em.find(PropertyAccessTypeEntity.class, id1);
    pate.writeData("data2");
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 5 with Priority

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

the class AuditReaderAPITest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    AuditedTestEntity ent1 = new AuditedTestEntity(1, "str1");
    NotAuditedTestEntity ent2 = new NotAuditedTestEntity(1, "str1");
    em.persist(ent1);
    em.persist(ent2);
    em.getTransaction().commit();
    em.getTransaction().begin();
    ent1 = em.find(AuditedTestEntity.class, 1);
    ent2 = em.find(NotAuditedTestEntity.class, 1);
    ent1.setStr1("str2");
    ent2.setStr1("str2");
    em.getTransaction().commit();
}
Also used : 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