Search in sources :

Example 1 with IdMapKeyEntity

use of org.hibernate.envers.test.integration.collection.mapkey.IdMapKeyEntity in project hibernate-orm by hibernate.

the class HasChangedIdMapKey method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    IdMapKeyEntity imke = new IdMapKeyEntity();
    // Revision 1 (intialy 1 mapping)
    em.getTransaction().begin();
    StrTestEntity ste1 = new StrTestEntity("x");
    StrTestEntity ste2 = new StrTestEntity("y");
    em.persist(ste1);
    em.persist(ste2);
    imke.getIdmap().put(ste1.getId(), ste1);
    em.persist(imke);
    em.getTransaction().commit();
    // Revision 2 (sse1: adding 1 mapping)
    em.getTransaction().begin();
    ste2 = em.find(StrTestEntity.class, ste2.getId());
    imke = em.find(IdMapKeyEntity.class, imke.getId());
    imke.getIdmap().put(ste2.getId(), ste2);
    em.getTransaction().commit();
    // 
    imke_id = imke.getId();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) IdMapKeyEntity(org.hibernate.envers.test.integration.collection.mapkey.IdMapKeyEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

EntityManager (javax.persistence.EntityManager)1 Priority (org.hibernate.envers.test.Priority)1 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)1 IdMapKeyEntity (org.hibernate.envers.test.integration.collection.mapkey.IdMapKeyEntity)1 Test (org.junit.Test)1