Search in sources :

Example 96 with StrTestEntity

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

the class DoubleFlushModMod method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrTestEntity fe = new StrTestEntity("x");
    em.persist(fe);
    em.flush();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    fe = em.find(StrTestEntity.class, fe.getId());
    fe.setStr("y");
    em.flush();
    fe.setStr("z");
    em.flush();
    em.getTransaction().commit();
    // 
    id = fe.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 97 with StrTestEntity

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

the class DoubleFlushModDel method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrTestEntity fe = new StrTestEntity("x");
    em.persist(fe);
    em.flush();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    fe = em.find(StrTestEntity.class, fe.getId());
    fe.setStr("y");
    em.flush();
    em.remove(em.find(StrTestEntity.class, fe.getId()));
    em.flush();
    em.getTransaction().commit();
    // 
    id = fe.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 98 with StrTestEntity

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

the class BasicDetachedList method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    StrTestEntity str1 = new StrTestEntity("str1");
    StrTestEntity str2 = new StrTestEntity("str2");
    ListRefCollEntity coll1 = new ListRefCollEntity(3, "coll1");
    // Revision 1
    em.getTransaction().begin();
    em.persist(str1);
    em.persist(str2);
    coll1.setCollection(new ArrayList<StrTestEntity>());
    coll1.getCollection().add(str1);
    em.persist(coll1);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    str2 = em.find(StrTestEntity.class, str2.getId());
    coll1 = em.find(ListRefCollEntity.class, coll1.getId());
    coll1.getCollection().add(str2);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    str1 = em.find(StrTestEntity.class, str1.getId());
    coll1 = em.find(ListRefCollEntity.class, coll1.getId());
    coll1.getCollection().remove(str1);
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    coll1 = em.find(ListRefCollEntity.class, coll1.getId());
    coll1.getCollection().clear();
    em.getTransaction().commit();
    // 
    str1_id = str1.getId();
    str2_id = str2.getId();
    coll1_id = coll1.getId();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) ListRefCollEntity(org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 99 with StrTestEntity

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

the class BasicJoinColumnSet method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    StrTestEntity str1 = new StrTestEntity("str1");
    StrTestEntity str2 = new StrTestEntity("str2");
    SetJoinColumnRefCollEntity coll1 = new SetJoinColumnRefCollEntity(3, "coll1");
    // Revision 1
    em.getTransaction().begin();
    em.persist(str1);
    em.persist(str2);
    coll1.setCollection(new HashSet<StrTestEntity>());
    coll1.getCollection().add(str1);
    em.persist(coll1);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    str2 = em.find(StrTestEntity.class, str2.getId());
    coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());
    coll1.getCollection().add(str2);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    str1 = em.find(StrTestEntity.class, str1.getId());
    coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());
    coll1.getCollection().remove(str1);
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    coll1 = em.find(SetJoinColumnRefCollEntity.class, coll1.getId());
    coll1.getCollection().clear();
    em.getTransaction().commit();
    // 
    str1_id = str1.getId();
    str2_id = str2.getId();
    coll1_id = coll1.getId();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) SetJoinColumnRefCollEntity(org.hibernate.envers.test.entities.onetomany.detached.SetJoinColumnRefCollEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 100 with StrTestEntity

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

the class BasicDetachedSet method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    StrTestEntity str1 = new StrTestEntity("str1");
    StrTestEntity str2 = new StrTestEntity("str2");
    SetRefCollEntity coll1 = new SetRefCollEntity(3, "coll1");
    // Revision 1
    em.getTransaction().begin();
    em.persist(str1);
    em.persist(str2);
    coll1.setCollection(new HashSet<StrTestEntity>());
    coll1.getCollection().add(str1);
    em.persist(coll1);
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    str2 = em.find(StrTestEntity.class, str2.getId());
    coll1 = em.find(SetRefCollEntity.class, coll1.getId());
    coll1.getCollection().add(str2);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    str1 = em.find(StrTestEntity.class, str1.getId());
    coll1 = em.find(SetRefCollEntity.class, coll1.getId());
    coll1.getCollection().remove(str1);
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    coll1 = em.find(SetRefCollEntity.class, coll1.getId());
    coll1.getCollection().clear();
    em.getTransaction().commit();
    // 
    str1_id = str1.getId();
    str2_id = str2.getId();
    coll1_id = coll1.getId();
}
Also used : SetRefCollEntity(org.hibernate.envers.test.entities.onetomany.detached.SetRefCollEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)103 Test (org.junit.Test)99 EntityManager (javax.persistence.EntityManager)51 Priority (org.hibernate.envers.test.Priority)48 Session (org.hibernate.Session)8 StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)8 TestForIssue (org.hibernate.testing.TestForIssue)5 ListRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity)4 SetRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.SetRefCollEntity)4 ManyToOneComponent (org.hibernate.envers.test.entities.components.relations.ManyToOneComponent)3 ManyToOneComponentTestEntity (org.hibernate.envers.test.entities.components.relations.ManyToOneComponentTestEntity)3 OneToManyComponent (org.hibernate.envers.test.entities.components.relations.OneToManyComponent)3 OneToManyComponentTestEntity (org.hibernate.envers.test.entities.components.relations.OneToManyComponentTestEntity)3 SortedSetEntity (org.hibernate.envers.test.entities.manytomany.SortedSetEntity)3 ListUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.ListUniEntity)3 SetUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.SetUniEntity)3 List (java.util.List)2 RevisionType (org.hibernate.envers.RevisionType)2 JoinTableEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.JoinTableEntity)2 MapUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.MapUniEntity)2