Search in sources :

Example 16 with Priority

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

the class UnspecifiedEnumTypeTest method initData.

@Test
@Priority(9)
public void initData() {
    Session session = getSession();
    // Revision 1
    session.getTransaction().begin();
    UnspecifiedEnumTypeEntity entity = new UnspecifiedEnumTypeEntity(UnspecifiedEnumTypeEntity.E1.X, UnspecifiedEnumTypeEntity.E2.A);
    session.persist(entity);
    session.getTransaction().commit();
    id = entity.getId();
    // Revision 2
    session.getTransaction().begin();
    entity = (UnspecifiedEnumTypeEntity) session.get(UnspecifiedEnumTypeEntity.class, entity.getId());
    entity.setEnum1(UnspecifiedEnumTypeEntity.E1.Y);
    entity.setEnum2(UnspecifiedEnumTypeEntity.E2.B);
    session.update(entity);
    session.getTransaction().commit();
    session.close();
}
Also used : UnspecifiedEnumTypeEntity(org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity) Session(org.hibernate.Session) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 17 with Priority

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

the class Dates method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    DateTestEntity dte = new DateTestEntity(new Date(12345000));
    em.persist(dte);
    id1 = dte.getId();
    em.getTransaction().commit();
    em.getTransaction().begin();
    dte = em.find(DateTestEntity.class, id1);
    dte.setDateValue(new Date(45678000));
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) Date(java.util.Date) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 18 with Priority

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

the class EmbeddableList1 method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    EmbeddableListEntity1 ele1 = new EmbeddableListEntity1();
    // Revision 1 (ele1: initially 1 element in both collections)
    em.getTransaction().begin();
    ele1.getComponentList().add(c3_1);
    em.persist(ele1);
    em.getTransaction().commit();
    // Revision (still 1) (ele1: removing non-existing element)
    em.getTransaction().begin();
    ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
    ele1.getComponentList().remove(c3_2);
    em.getTransaction().commit();
    // Revision 2 (ele1: adding one element)
    em.getTransaction().begin();
    ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
    ele1.getComponentList().add(c3_2);
    em.getTransaction().commit();
    // Revision 3 (ele1: adding one existing element)
    em.getTransaction().begin();
    ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
    ele1.getComponentList().add(c3_1);
    em.getTransaction().commit();
    // Revision 4 (ele1: removing one existing element)
    em.getTransaction().begin();
    ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
    ele1.getComponentList().remove(c3_2);
    em.getTransaction().commit();
    ele1_id = ele1.getId();
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) EmbeddableListEntity1(org.hibernate.envers.test.entities.collection.EmbeddableListEntity1) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 19 with Priority

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

the class IdMapKey method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    IdMapKeyEntity imke = new IdMapKeyEntity();
    // Revision 1 (intialy 1 mapping)
    em.getTransaction().begin();
    StrTestEntity ste1 = new StrTestEntity("x");
    StrTestEntity ste2 = new StrTestEntity("y");
    em.persist(ste1);
    em.persist(ste2);
    imke.getIdmap().put(ste1.getId(), ste1);
    em.persist(imke);
    em.getTransaction().commit();
    // Revision 2 (sse1: adding 1 mapping)
    em.getTransaction().begin();
    ste2 = em.find(StrTestEntity.class, ste2.getId());
    imke = em.find(IdMapKeyEntity.class, imke.getId());
    imke.getIdmap().put(ste2.getId(), ste2);
    em.getTransaction().commit();
    //
    imke_id = imke.getId();
    ste1_id = ste1.getId();
    ste2_id = ste2.getId();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 20 with Priority

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

the class EnumSet method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    EnumSetEntity sse1 = new EnumSetEntity();
    // Revision 1 (sse1: initialy 1 element)
    em.getTransaction().begin();
    sse1.getEnums1().add(E1.X);
    sse1.getEnums2().add(E2.A);
    em.persist(sse1);
    em.getTransaction().commit();
    // Revision 2 (sse1: adding 1 element/removing a non-existing element)
    em.getTransaction().begin();
    sse1 = em.find(EnumSetEntity.class, sse1.getId());
    sse1.getEnums1().add(E1.Y);
    sse1.getEnums2().remove(E2.B);
    em.getTransaction().commit();
    // Revision 3 (sse1: removing 1 element/adding an exisiting element)
    em.getTransaction().begin();
    sse1 = em.find(EnumSetEntity.class, sse1.getId());
    sse1.getEnums1().remove(E1.X);
    sse1.getEnums2().add(E2.A);
    em.getTransaction().commit();
    //
    sse1_id = sse1.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) EnumSetEntity(org.hibernate.envers.test.entities.collection.EnumSetEntity) 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