@Override public void updateDivorce(Divorce d) { em.getTransaction().begin(); Divorce target = em.find(Divorce.class, d.getId()); target.setCountry(d.getCountry()); target.setEventDate(d.getEventDate()); target.setPerson(d.getPerson()); target.setState_province(d.getState_province()); target.setTown(d.getTown()); target.setEx(d.getEx()); em.merge(target); em.getTransaction().commit(); }
@Override public void addDivorce(Divorce divorceRecord) { Divorce d2 = new Divorce(); d2.setEx(divorceRecord.getPerson()); d2.setEventDate(divorceRecord.getEventDate()); d2.setCountry(divorceRecord.getCountry()); d2.setPerson(divorceRecord.getEx()); d2.setState_province(divorceRecord.getState_province()); d2.setTown(divorceRecord.getTown()); em.getTransaction().begin(); em.persist(divorceRecord); em.persist(d2); em.getTransaction().commit(); }