Search in sources :

Example 6 with Priority

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

the class ColumnScalePrecisionTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    ScalePrecisionEntity entity = new ScalePrecisionEntity(13.0);
    em.persist(entity);
    em.getTransaction().commit();
    id = entity.getId();
    auditTable = metadata().getEntityBinding("org.hibernate.envers.test.integration.basic.ScalePrecisionEntity_AUD").getTable();
    originalTable = metadata().getEntityBinding("org.hibernate.envers.test.integration.basic.ScalePrecisionEntity").getTable();
}
Also used : EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 7 with Priority

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

the class OneToManyCache method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    SetRefEdEntity ed1 = new SetRefEdEntity(1, "data_ed_1");
    SetRefEdEntity ed2 = new SetRefEdEntity(2, "data_ed_2");
    SetRefIngEntity ing1 = new SetRefIngEntity(1, "data_ing_1");
    SetRefIngEntity ing2 = new SetRefIngEntity(2, "data_ing_2");
    // Revision 1
    em.getTransaction().begin();
    em.persist(ed1);
    em.persist(ed2);
    ing1.setReference(ed1);
    ing2.setReference(ed1);
    em.persist(ing1);
    em.persist(ing2);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    ing1 = em.find(SetRefIngEntity.class, ing1.getId());
    ing2 = em.find(SetRefIngEntity.class, ing2.getId());
    ed2 = em.find(SetRefEdEntity.class, ed2.getId());
    ing1.setReference(ed2);
    ing2.setReference(ed2);
    em.getTransaction().commit();
    //
    ed1_id = ed1.getId();
    ed2_id = ed2.getId();
    ing1_id = ing1.getId();
    ing2_id = ing2.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) SetRefIngEntity(org.hibernate.envers.test.entities.onetomany.SetRefIngEntity) SetRefEdEntity(org.hibernate.envers.test.entities.onetomany.SetRefEdEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 8 with Priority

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

the class OneToOneCache method initData.

@Test
@Priority(10)
public void initData() {
    BiRefEdEntity ed1 = new BiRefEdEntity(1, "data_ed_1");
    BiRefEdEntity ed2 = new BiRefEdEntity(2, "data_ed_2");
    BiRefIngEntity ing1 = new BiRefIngEntity(3, "data_ing_1");
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    ing1.setReference(ed1);
    em.persist(ed1);
    em.persist(ed2);
    em.persist(ing1);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    ing1 = em.find(BiRefIngEntity.class, ing1.getId());
    ed2 = em.find(BiRefEdEntity.class, ed2.getId());
    ing1.setReference(ed2);
    em.getTransaction().commit();
    ed1_id = ed1.getId();
    ed2_id = ed2.getId();
    ing1_id = ing1.getId();
}
Also used : BiRefIngEntity(org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefIngEntity) EntityManager(javax.persistence.EntityManager) BiRefEdEntity(org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefEdEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 9 with Priority

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

the class EnumMapTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getOrCreateEntityManager();
    try {
        // revision 1
        EnumMapEntity entity = new EnumMapEntity();
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_A, new EnumMapType("A"));
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_B, new EnumMapType("B"));
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        // revision 2
        em.getTransaction().begin();
        entity = em.find(EnumMapEntity.class, entity.getId());
        entity.getTypes().remove(EnumMapEntity.EnumType.TYPE_A);
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_C, new EnumMapType("C"));
        em.getTransaction().commit();
        entityId = entity.getId();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) EnumMapType(org.hibernate.envers.test.entities.collection.EnumMapType) EnumMapEntity(org.hibernate.envers.test.entities.collection.EnumMapEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 10 with Priority

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

the class CollectionOfComponents method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    ComponentSetTestEntity cte1 = new ComponentSetTestEntity();
    ComponentSetTestEntity cte2 = new ComponentSetTestEntity();
    cte2.getComps().add(new Component1("string1", null));
    em.persist(cte2);
    em.persist(cte1);
    em.getTransaction().commit();
    // Revision 2
    em = getEntityManager();
    em.getTransaction().begin();
    cte1 = em.find(ComponentSetTestEntity.class, cte1.getId());
    cte1.getComps().add(new Component1("a", "b"));
    em.getTransaction().commit();
    id1 = cte1.getId();
    id2 = cte2.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) Component1(org.hibernate.envers.test.entities.components.Component1) ComponentSetTestEntity(org.hibernate.envers.test.entities.components.ComponentSetTestEntity) 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