Search in sources :

Example 1 with CompositeCustomTypeSetEntity

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

the class CompositeCustomType method testRemoval.

@Test
@TestForIssue(jiraKey = "HHH-9207")
@FailureExpected(jiraKey = "HHH-9207")
public void testRemoval() {
    EntityManager em = getEntityManager();
    final Component comp1 = new Component(null, 11);
    final Component comp2 = new Component(null, 22);
    final CompositeCustomTypeSetEntity entity = new CompositeCustomTypeSetEntity();
    entity.setComponents(new HashSet<Component>());
    entity.getComponents().add(comp1);
    entity.getComponents().add(comp2);
    em.getTransaction().begin();
    em.persist(entity);
    em.getTransaction().commit();
    em.getTransaction().begin();
    entity.getComponents().remove(comp1);
    em.getTransaction().commit();
    CompositeCustomTypeSetEntity rev1 = getAuditReader().find(CompositeCustomTypeSetEntity.class, entity.getId(), 1);
    CompositeCustomTypeSetEntity rev2 = getAuditReader().find(CompositeCustomTypeSetEntity.class, entity.getId(), 2);
    assertEquals("Unexpected components", TestTools.makeSet(comp1, comp2), rev1.getComponents());
    assertEquals("Unexpected components", TestTools.makeSet(comp2), rev2.getComponents());
}
Also used : CompositeCustomTypeSetEntity(org.hibernate.envers.test.entities.collection.CompositeCustomTypeSetEntity) EntityManager(javax.persistence.EntityManager) Component(org.hibernate.envers.test.entities.customtype.Component) Test(org.junit.Test) FailureExpected(org.hibernate.testing.FailureExpected) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

EntityManager (javax.persistence.EntityManager)1 CompositeCustomTypeSetEntity (org.hibernate.envers.test.entities.collection.CompositeCustomTypeSetEntity)1 Component (org.hibernate.envers.test.entities.customtype.Component)1 FailureExpected (org.hibernate.testing.FailureExpected)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.Test)1