删除一个分类(作为外键),有这分类的产品要设相对字段为null
public ModelAndView del(HttpServletRequest request,HttpServletResponse response) throws Exception {long id = Long.parseLong(request.getParameter("id"));//新加的编历person,修改personHrJob hrjob = hrJobService.getHrJob(id);Set hrjobSet = hrjob.getHrPersons();Iterator iterator = hrjobSet.iterator();iterator.hasNext();while(iterator.hasNext()){HrPerson hrPerson = (HrPerson)iterator.next();hrPerson.setHrJob(null);hrPersonService.edit(hrPerson);}//新加的编历person,修改personhrJobService.delById(id);Map model = new HashMap(); model.put("msg","删除职位成功!"); model.put("url","manage/hr/job/list.htm");return new ModelAndView("/WEB-INF/jsp/messagejs.jsp","model", model);}