Search in sources :

Example 26 with Priority

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

the class EmbeddableWithDeclaredDataTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    EntityWithEmbeddableWithDeclaredData entity = new EntityWithEmbeddableWithDeclaredData();
    entity.setName("Entity 1");
    entity.setValue(new EmbeddableWithDeclaredData(42, "TestCodeart"));
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    em.persist(entity);
    tx.commit();
    em.close();
    id = entity.getId();
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 27 with Priority

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

the class NotAuditedManyToOneInComponent method initData.

@Test
@Priority(10)
public void initData() {
    // No revision
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    UnversionedStrTestEntity ste1 = new UnversionedStrTestEntity();
    ste1.setStr("str1");
    UnversionedStrTestEntity ste2 = new UnversionedStrTestEntity();
    ste2.setStr("str2");
    em.persist(ste1);
    em.persist(ste2);
    em.getTransaction().commit();
    // Revision 1
    em = getEntityManager();
    em.getTransaction().begin();
    NotAuditedManyToOneComponentTestEntity mtocte1 = new NotAuditedManyToOneComponentTestEntity(new NotAuditedManyToOneComponent(ste1, "data1"));
    em.persist(mtocte1);
    em.getTransaction().commit();
    // No revision
    em = getEntityManager();
    em.getTransaction().begin();
    mtocte1 = em.find(NotAuditedManyToOneComponentTestEntity.class, mtocte1.getId());
    mtocte1.getComp1().setEntity(ste2);
    em.getTransaction().commit();
    // Revision 2
    em = getEntityManager();
    em.getTransaction().begin();
    mtocte1 = em.find(NotAuditedManyToOneComponentTestEntity.class, mtocte1.getId());
    mtocte1.getComp1().setData("data2");
    em.getTransaction().commit();
    mtocte_id1 = mtocte1.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) NotAuditedManyToOneComponentTestEntity(org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponentTestEntity) UnversionedStrTestEntity(org.hibernate.envers.test.entities.UnversionedStrTestEntity) NotAuditedManyToOneComponent(org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponent) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 28 with Priority

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

the class CompositeCustom method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    CompositeCustomTypeEntity ccte = new CompositeCustomTypeEntity();
    // Revision 1 (persisting 1 entity)
    em.getTransaction().begin();
    ccte.setComponent(new Component("a", 1));
    em.persist(ccte);
    em.getTransaction().commit();
    // Revision 2 (changing the component)
    em.getTransaction().begin();
    ccte = em.find(CompositeCustomTypeEntity.class, ccte.getId());
    ccte.getComponent().setProp1("b");
    em.getTransaction().commit();
    // Revision 3 (replacing the component)
    em.getTransaction().begin();
    ccte = em.find(CompositeCustomTypeEntity.class, ccte.getId());
    ccte.setComponent(new Component("c", 3));
    em.getTransaction().commit();
    //
    ccte_id = ccte.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) CompositeCustomTypeEntity(org.hibernate.envers.test.entities.customtype.CompositeCustomTypeEntity) Component(org.hibernate.envers.test.entities.customtype.Component) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 29 with Priority

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

the class DoubleFlushAddDel 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.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 30 with Priority

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

the class DoubleFlushAddMod 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();
    fe.setStr("y");
    em.flush();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    fe = em.find(StrTestEntity.class, fe.getId());
    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)

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