public Dependent4 persistDependent4(EntityManager em, int id, Employee4 p) { Dependent4 c = new Dependent4(); c.setId(id); c.setParent(p); em.persist(c); return c; }
public Employee4 mergeEmployee4(EntityManager em, int id) { Employee4 e = new Employee4(); e.setAge(id); e = em.merge(e); for (int i = 0; i < numDependentsPerEmployee; i++) { Dependent4 d = new Dependent4(); d.setId(dId4++); d.setParent(e); // do not need to merge d, as Employee is cascade.All d = em.merge(d); e.addChild(d); } return e; }