Search in sources :

Example 1 with EnumMapType

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

the class EnumMapTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getOrCreateEntityManager();
    try {
        // revision 1
        EnumMapEntity entity = new EnumMapEntity();
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_A, new EnumMapType("A"));
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_B, new EnumMapType("B"));
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        // revision 2
        em.getTransaction().begin();
        entity = em.find(EnumMapEntity.class, entity.getId());
        entity.getTypes().remove(EnumMapEntity.EnumType.TYPE_A);
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_C, new EnumMapType("C"));
        em.getTransaction().commit();
        entityId = entity.getId();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) EnumMapType(org.hibernate.envers.test.entities.collection.EnumMapType) EnumMapEntity(org.hibernate.envers.test.entities.collection.EnumMapEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

EntityManager (javax.persistence.EntityManager)1 Priority (org.hibernate.envers.test.Priority)1 EnumMapEntity (org.hibernate.envers.test.entities.collection.EnumMapEntity)1 EnumMapType (org.hibernate.envers.test.entities.collection.EnumMapType)1 Test (org.junit.Test)1