Search in sources :

Example 86 with StrTestEntity

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

the class QueryingWithProxyObjectTest method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    getSession().getTransaction().begin();
    StrTestEntity ste = new StrTestEntity("data");
    getSession().persist(ste);
    getSession().getTransaction().commit();
    id = ste.getId();
    getSession().close();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 87 with StrTestEntity

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

the class OutsideTransactionTest method testInsertOutsideActiveTransaction.

@Test(expected = TransactionRequiredException.class)
public void testInsertOutsideActiveTransaction() {
    Session session = openSession();
    // Illegal insertion of entity outside of active transaction.
    StrTestEntity entity = new StrTestEntity("data");
    session.persist(entity);
    session.flush();
    session.close();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Session(org.hibernate.Session) Test(org.junit.Test)

Example 88 with StrTestEntity

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

the class OutsideTransactionTest method testDeleteOutsideActiveTransaction.

@Test(expected = TransactionRequiredException.class)
public void testDeleteOutsideActiveTransaction() {
    Session session = openSession();
    // Revision 1
    session.getTransaction().begin();
    StrTestEntity entity = new StrTestEntity("data");
    session.persist(entity);
    session.getTransaction().commit();
    // Illegal removal of entity outside of active transaction.
    session.delete(entity);
    session.flush();
    session.close();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Session(org.hibernate.Session) Test(org.junit.Test)

Example 89 with StrTestEntity

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

the class OutsideTransactionTest method testUpdateOutsideActiveTransaction.

@Test(expected = TransactionRequiredException.class)
public void testUpdateOutsideActiveTransaction() {
    Session session = openSession();
    // Revision 1
    session.getTransaction().begin();
    StrTestEntity entity = new StrTestEntity("data");
    session.persist(entity);
    session.getTransaction().commit();
    // Illegal modification of entity state outside of active transaction.
    entity.setStr("modified data");
    session.update(entity);
    session.flush();
    session.close();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Session(org.hibernate.Session) Test(org.junit.Test)

Example 90 with StrTestEntity

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

the class BasicDetachedList method testHistoryOfColl1.

@Test
public void testHistoryOfColl1() {
    StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
    StrTestEntity str2 = getEntityManager().find(StrTestEntity.class, str2_id);
    ListRefCollEntity rev1 = getAuditReader().find(ListRefCollEntity.class, coll1_id, 1);
    ListRefCollEntity rev2 = getAuditReader().find(ListRefCollEntity.class, coll1_id, 2);
    ListRefCollEntity rev3 = getAuditReader().find(ListRefCollEntity.class, coll1_id, 3);
    ListRefCollEntity rev4 = getAuditReader().find(ListRefCollEntity.class, coll1_id, 4);
    assert TestTools.checkCollection(rev1.getCollection(), str1);
    assert TestTools.checkCollection(rev2.getCollection(), str1, str2);
    assert TestTools.checkCollection(rev3.getCollection(), str2);
    assert TestTools.checkCollection(rev4.getCollection());
    assert "coll1".equals(rev1.getData());
    assert "coll1".equals(rev2.getData());
    assert "coll1".equals(rev3.getData());
    assert "coll1".equals(rev4.getData());
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) ListRefCollEntity(org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity) Test(org.junit.Test)

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