public ClazzDetail mergeClazzDetail(ClazzDetail clazzDetail) { try { ClazzDetail cd = em.find(ClazzDetail.class, clazzDetail.getClazz_DETAIL_ID()); cd.setClazz(clazzDetail.getClazz()); cd.setClazz_DETAIL_ID(clazzDetail.getClazz_DETAIL_ID()); cd.setStudent(clazzDetail.getStudent()); return em.merge(cd); } catch (Exception e) { throw new EJBException(e.getMessage()); } }
@Override public ClazzDetail addClazzDetail(int classID, int studentID) { Clazz clazz = em.find(Clazz.class, classID); Student student = em.find(Student.class, studentID); if ((clazz != null) && (student != null)) { ClazzDetail cd = new ClazzDetail(); cd.setClazz(clazz); cd.setStudent(student); return this.persistClazzDetail(cd); } return null; }