Search in sources :

Example 86 with Priority

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

the class DifferentDBSchemaTest method initData.

@Test
@Priority(10)
public void initData() throws InterruptedException {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrTestEntity ste = new StrTestEntity("x");
    em.persist(ste);
    steId = ste.getId();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    ste = em.find(StrTestEntity.class, steId);
    ste.setStr("y");
    em.getTransaction().commit();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 87 with Priority

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

the class Inherited method initData.

@Test
@Priority(10)
public void initData() throws InterruptedException {
    timestamp1 = System.currentTimeMillis();
    Thread.sleep(100);
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrTestEntity te = new StrTestEntity("x");
    em.persist(te);
    id = te.getId();
    em.getTransaction().commit();
    timestamp2 = System.currentTimeMillis();
    Thread.sleep(100);
    // Revision 2
    em.getTransaction().begin();
    te = em.find(StrTestEntity.class, id);
    te.setStr("y");
    em.getTransaction().commit();
    timestamp3 = System.currentTimeMillis();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 88 with Priority

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

the class SimpleQuery method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
    StrIntTestEntity site2 = new StrIntTestEntity("a", 10);
    StrIntTestEntity site3 = new StrIntTestEntity("b", 5);
    em.persist(site1);
    em.persist(site2);
    em.persist(site3);
    id1 = site1.getId();
    id2 = site2.getId();
    id3 = site3.getId();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    mulId1 = new MulId(1, 2);
    em.persist(new MulIdTestEntity(mulId1.getId1(), mulId1.getId2(), "data"));
    embId1 = new EmbId(3, 4);
    em.persist(new EmbIdTestEntity(embId1, "something"));
    site1 = em.find(StrIntTestEntity.class, id1);
    site2 = em.find(StrIntTestEntity.class, id2);
    site1.setStr1("aBc");
    site2.setNumber(20);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    site3 = em.find(StrIntTestEntity.class, id3);
    site3.setStr1("a");
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    site1 = em.find(StrIntTestEntity.class, id1);
    em.remove(site1);
    em.getTransaction().commit();
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) EntityManager(javax.persistence.EntityManager) MulIdTestEntity(org.hibernate.envers.test.entities.ids.MulIdTestEntity) EmbIdTestEntity(org.hibernate.envers.test.entities.ids.EmbIdTestEntity) EmbId(org.hibernate.envers.test.entities.ids.EmbId) MulId(org.hibernate.envers.test.entities.ids.MulId) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 89 with Priority

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

the class StoreDeletedData method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    // Revision 1
    em.getTransaction().begin();
    StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
    em.persist(site1);
    id1 = site1.getId();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    em.remove(site1);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    StrIntTestEntity site2 = new StrIntTestEntity("b", 20);
    em.persist(site2);
    id2 = site2.getId();
    StrIntTestEntity site3 = new StrIntTestEntity("c", 30);
    em.persist(site3);
    id3 = site3.getId();
    em.getTransaction().commit();
    // Revision 4
    em.getTransaction().begin();
    em.remove(site2);
    em.remove(site3);
    em.getTransaction().commit();
    em.close();
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 90 with Priority

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

the class AuditedCollectionProxyTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    ListRefEdEntity listReferencedEntity1 = new ListRefEdEntity(Integer.valueOf(1), "str1");
    ListRefIngEntity refingEntity1 = new ListRefIngEntity(Integer.valueOf(1), "refing1", listReferencedEntity1);
    // Revision 1
    em.getTransaction().begin();
    em.persist(listReferencedEntity1);
    em.persist(refingEntity1);
    em.getTransaction().commit();
    id_ListRefEdEntity1 = listReferencedEntity1.getId();
    // Revision 2
    ListRefIngEntity refingEntity2 = new ListRefIngEntity(Integer.valueOf(2), "refing2", listReferencedEntity1);
    em.getTransaction().begin();
    em.persist(refingEntity2);
    em.getTransaction().commit();
}
Also used : EntityManager(javax.persistence.EntityManager) ListRefIngEntity(org.hibernate.envers.test.entities.onetomany.ListRefIngEntity) ListRefEdEntity(org.hibernate.envers.test.entities.onetomany.ListRefEdEntity) 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