Search in sources :

Example 1 with ComponentSetTestEntity

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

the class CollectionOfComponents method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    ComponentSetTestEntity cte1 = new ComponentSetTestEntity();
    ComponentSetTestEntity cte2 = new ComponentSetTestEntity();
    cte2.getComps().add(new Component1("string1", null));
    em.persist(cte2);
    em.persist(cte1);
    em.getTransaction().commit();
    // Revision 2
    em = getEntityManager();
    em.getTransaction().begin();
    cte1 = em.find(ComponentSetTestEntity.class, cte1.getId());
    cte1.getComps().add(new Component1("a", "b"));
    em.getTransaction().commit();
    id1 = cte1.getId();
    id2 = cte2.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) Component1(org.hibernate.envers.test.entities.components.Component1) ComponentSetTestEntity(org.hibernate.envers.test.entities.components.ComponentSetTestEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 2 with ComponentSetTestEntity

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

the class CollectionOfComponents method testCollectionOfEmbeddableWithNullValue.

@Test
@TestForIssue(jiraKey = "HHH-8968")
public void testCollectionOfEmbeddableWithNullValue() {
    final Component1 componentV1 = new Component1("string1", null);
    final ComponentSetTestEntity entityV1 = getAuditReader().find(ComponentSetTestEntity.class, id2, 1);
    assertEquals("Expected a component", Collections.singleton(componentV1), entityV1.getComps());
}
Also used : Component1(org.hibernate.envers.test.entities.components.Component1) ComponentSetTestEntity(org.hibernate.envers.test.entities.components.ComponentSetTestEntity) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

Component1 (org.hibernate.envers.test.entities.components.Component1)2 ComponentSetTestEntity (org.hibernate.envers.test.entities.components.ComponentSetTestEntity)2 Test (org.junit.Test)2 EntityManager (javax.persistence.EntityManager)1 Priority (org.hibernate.envers.test.Priority)1 TestForIssue (org.hibernate.testing.TestForIssue)1