问题描述
- hibernate的联级更新,更新总是没有反应
-
Userrole.hbm.xml>
>
>
>
>Right.hbm.xml
>
>java代码:
public void updateRole(Userrole userrole, Integer[] ids)
{
Userrole userrole2 = (Userrole) userroleDao.findById(Userrole.class, userrole.getRoleid());if(ids != null && ids.length > 0) { Set set = new HashSet(); for (Integer integer : ids) { Right right = (Right) rightDao.findById(Right.class, integer); System.out.println(right.getNode().getId()); if(right.getUserrole().getRoleid().intValue() != userrole2.getRoleid().intValue()) { Right right2 = new Right(); Node node = new Node(); node.setId(right.getNode().getId()); right2.setNode(node); right2.setRightchildurl(right.getRightchildurl()); right2.setRightname(right.getRightname()); right2.setRighturl(right.getRighturl()); Userrole userrole3 = new Userrole(); userrole3.setRoleid(userrole2.getRoleid()); right2.setUserrole(userrole3); set.add(right2); } else { set.add(right); } } userrole2.setRights(set); } else { userrole2.setRolename(userrole.getRolename()); userrole2.setRoledesc(userrole.getRoledesc()); } userroleDao.update(userrole2); }
更新不了,求大神们指点下
时间: 2024-12-03 00:09:32