em.getTransaction().rollback();
em.getTransaction().begin();
lStored = em.merge(lStored);
em.refresh(lStored);
Measure m = new Measure();
lStored.setMeasure(m);
em.persist(lStored);
assertEquals("Measure should be persisted together with leaf", 1,
((Long)em.createQuery("select count(*) from Measure").getSingleResult()).longValue());
em.getTransaction().commit();
em.getTransaction().begin();
em.remove(lStored);
assertEquals("Measure should be deleted together with leaf", 0,
((Long)em.createQuery("select count(*) from Measure").getSingleResult()).longValue());
em.getTransaction().rollback();
em.getTransaction().begin();
lStored = em.merge(lStored);
assertEquals("Measure should be persisted together with leaf", 1,
((Long)em.createQuery("select count(*) from Measure").getSingleResult()).longValue());
Measure m2 = new Measure();
m2.setName("m2");
lStored.setMeasure(m2);
em.persist(lStored);
assertEquals("Measure should be persisted together with leaf", 2,
((Long)em.createQuery("select count(*) from Measure").getSingleResult()).longValue());