Search in sources :

Example 11 with Component1

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

the class Components method testHistoryOfId3.

@Test
public void testHistoryOfId3() {
    ComponentTestEntity ver1 = new ComponentTestEntity(id3, new Component1("a3", "b3"), null);
    ComponentTestEntity ver2 = new ComponentTestEntity(id3, new Component1("a3", "b3'"), null);
    assert getAuditReader().find(ComponentTestEntity.class, id3, 1).equals(ver1);
    assert getAuditReader().find(ComponentTestEntity.class, id3, 2).equals(ver1);
    assert getAuditReader().find(ComponentTestEntity.class, id3, 3).equals(ver2);
    assert getAuditReader().find(ComponentTestEntity.class, id3, 4).equals(ver2);
}
Also used : Component1(org.hibernate.envers.test.entities.components.Component1) ComponentTestEntity(org.hibernate.envers.test.entities.components.ComponentTestEntity) Test(org.junit.Test)

Example 12 with Component1

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

the class ComponentMapKey method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    ComponentMapKeyEntity imke = new ComponentMapKeyEntity();
    // Revision 1 (intialy 1 mapping)
    em.getTransaction().begin();
    ComponentTestEntity cte1 = new ComponentTestEntity(new Component1("x1", "y2"), new Component2("a1", "b2"));
    ComponentTestEntity cte2 = new ComponentTestEntity(new Component1("x1", "y2"), new Component2("a1", "b2"));
    em.persist(cte1);
    em.persist(cte2);
    imke.getIdmap().put(cte1.getComp1(), cte1);
    em.persist(imke);
    em.getTransaction().commit();
    // Revision 2 (sse1: adding 1 mapping)
    em.getTransaction().begin();
    cte2 = em.find(ComponentTestEntity.class, cte2.getId());
    imke = em.find(ComponentMapKeyEntity.class, imke.getId());
    imke.getIdmap().put(cte2.getComp1(), cte2);
    em.getTransaction().commit();
    // 
    cmke_id = imke.getId();
    cte1_id = cte1.getId();
    cte2_id = cte2.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) Component1(org.hibernate.envers.test.entities.components.Component1) Component2(org.hibernate.envers.test.entities.components.Component2) ComponentTestEntity(org.hibernate.envers.test.entities.components.ComponentTestEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

Component1 (org.hibernate.envers.test.entities.components.Component1)12 Test (org.junit.Test)12 ComponentTestEntity (org.hibernate.envers.test.entities.components.ComponentTestEntity)8 EntityManager (javax.persistence.EntityManager)7 Priority (org.hibernate.envers.test.Priority)7 Component2 (org.hibernate.envers.test.entities.components.Component2)5 ComponentSetTestEntity (org.hibernate.envers.test.entities.components.ComponentSetTestEntity)2 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)1 ComponentMapKeyEntity (org.hibernate.envers.test.integration.collection.mapkey.ComponentMapKeyEntity)1 PartialModifiedFlagsEntity (org.hibernate.envers.test.integration.modifiedflags.entities.PartialModifiedFlagsEntity)1 WithModifiedFlagReferencingEntity (org.hibernate.envers.test.integration.modifiedflags.entities.WithModifiedFlagReferencingEntity)1 TestForIssue (org.hibernate.testing.TestForIssue)1