2 u011112210 u011112210 于 2014.08.21 10:05 提问

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);
}

更新不了,求大神们指点下

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!