Search in sources :

Example 1 with UnspecifiedEnumTypeEntity

use of org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity 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 2 with UnspecifiedEnumTypeEntity

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

the class UnspecifiedEnumTypeTest method testHistoryOfEnums.

@Test
@Priority(7)
public void testHistoryOfEnums() {
    UnspecifiedEnumTypeEntity ver1 = new UnspecifiedEnumTypeEntity(UnspecifiedEnumTypeEntity.E1.X, UnspecifiedEnumTypeEntity.E2.A, id);
    UnspecifiedEnumTypeEntity ver2 = new UnspecifiedEnumTypeEntity(UnspecifiedEnumTypeEntity.E1.Y, UnspecifiedEnumTypeEntity.E2.B, id);
    Assert.assertEquals(ver1, getAuditReader().find(UnspecifiedEnumTypeEntity.class, id, 1));
    Assert.assertEquals(ver2, getAuditReader().find(UnspecifiedEnumTypeEntity.class, id, 2));
}
Also used : UnspecifiedEnumTypeEntity(org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

Priority (org.hibernate.envers.test.Priority)2 UnspecifiedEnumTypeEntity (org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity)2 Test (org.junit.Test)2 Session (org.hibernate.Session)1