use of org.hibernate.envers.test.entities.collection.EmbeddableListEntity1 in project hibernate-orm by hibernate.
the class EmbeddableList1 method testHistoryOfEle1.
@Test
public void testHistoryOfEle1() {
EmbeddableListEntity1 rev1 = getAuditReader().find(EmbeddableListEntity1.class, ele1_id, 1);
EmbeddableListEntity1 rev2 = getAuditReader().find(EmbeddableListEntity1.class, ele1_id, 2);
EmbeddableListEntity1 rev3 = getAuditReader().find(EmbeddableListEntity1.class, ele1_id, 3);
EmbeddableListEntity1 rev4 = getAuditReader().find(EmbeddableListEntity1.class, ele1_id, 4);
assertEquals(Collections.singletonList(c3_1), rev1.getComponentList());
assertEquals(Arrays.asList(c3_1, c3_2), rev2.getComponentList());
assertEquals(Arrays.asList(c3_1, c3_2, c3_1), rev3.getComponentList());
assertEquals(Arrays.asList(c3_1, c3_1), rev4.getComponentList());
}
use of org.hibernate.envers.test.entities.collection.EmbeddableListEntity1 in project hibernate-orm by hibernate.
the class EmbeddableList1 method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
EmbeddableListEntity1 ele1 = new EmbeddableListEntity1();
// Revision 1 (ele1: initially 1 element in both collections)
em.getTransaction().begin();
ele1.getComponentList().add(c3_1);
em.persist(ele1);
em.getTransaction().commit();
// Revision (still 1) (ele1: removing non-existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().remove(c3_2);
em.getTransaction().commit();
// Revision 2 (ele1: adding one element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().add(c3_2);
em.getTransaction().commit();
// Revision 3 (ele1: adding one existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().add(c3_1);
em.getTransaction().commit();
// Revision 4 (ele1: removing one existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().remove(c3_2);
em.getTransaction().commit();
ele1_id = ele1.getId();
em.close();
}
use of org.hibernate.envers.test.entities.collection.EmbeddableListEntity1 in project hibernate-orm by hibernate.
the class HasChangedComponentCollection method testHasChangedEle.
@Test
public void testHasChangedEle() {
List list = queryForPropertyHasChanged(EmbeddableListEntity1.class, ele1_id, "componentList");
assertEquals(4, list.size());
assertEquals(makeList(1, 3, 4, 5), extractRevisionNumbers(list));
list = queryForPropertyHasChanged(EmbeddableListEntity1.class, ele1_id, "otherData");
assertEquals(3, list.size());
assertEquals(makeList(1, 2, 6), extractRevisionNumbers(list));
}
use of org.hibernate.envers.test.entities.collection.EmbeddableListEntity1 in project hibernate-orm by hibernate.
the class HasChangedComponentCollection method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 (ele1: initially 1 element in both collections)
em.getTransaction().begin();
EmbeddableListEntity1 ele1 = new EmbeddableListEntity1();
ele1.setOtherData("data");
ele1.getComponentList().add(c3_1);
em.persist(ele1);
em.getTransaction().commit();
// Revision (still 1) (ele1: removing non-existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().remove(c3_2);
em.getTransaction().commit();
// Revision 2 (ele1: updating singular property and removing non-existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.setOtherData("modified");
ele1.getComponentList().remove(c3_2);
ele1 = em.merge(ele1);
em.getTransaction().commit();
// Revision 3 (ele1: adding one element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().add(c3_2);
em.getTransaction().commit();
// Revision 4 (ele1: adding one existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().add(c3_1);
em.getTransaction().commit();
// Revision 5 (ele1: removing one existing element)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.getComponentList().remove(c3_2);
em.getTransaction().commit();
// Revision 6 (ele1: changing singular property only)
em.getTransaction().begin();
ele1 = em.find(EmbeddableListEntity1.class, ele1.getId());
ele1.setOtherData("another modification");
ele1 = em.merge(ele1);
em.getTransaction().commit();
ele1_id = ele1.getId();
em.close();
}
Aggregations