Score
0
Watch 3.1K Star 6.8K Fork 3.3K

卓源软件 / JeeSite 4.xJavaAGPL-3.0

user.getUserRoleList()方法的返回结果中只有roleCode,没有userCode

Open
大西洲总督  Opened this issue

重现步骤

    UserRole where = new UserRole();
    where.setUserCode(user.getUserCode());
    userRoleDao.deleteByEntity(where);
    // UserRole里只有roleCode,没有userCode,需要手动添加
    List<UserRole> userRoleList = user.getUserRoleList();
    for (UserRole userRole : userRoleList) {
        // 在这里添加userCode居然会直接影响user...
        userRole.setUserCode(user.getUserCode());
    }
    // 批量添加角色
    // 上面是遍历userRoleList添加的userCode,但是直接影响了user
    // 再次getUserRoleList,里面又有userCode了
    userRoleDao.insertBatch(user.getUserRoleList());
    UserUtils.clearCache(user);

报错信息

    // 如果不手动添加userCode,按照下面的代码执行:
    UserRole where = new UserRole();
    where.setUserCode(user.getUserCode());
    userRoleDao.deleteByEntity(where);
    userRoleDao.insertBatch(user.getUserRoleList()); 
    UserUtils.clearCache(user);
    
    // insertBatch时会报错“Column 'user_code' cannot be null”
total 1 participants

Comments (0)

Sign in to comment

Assignees
Labels
Not set
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority
Java
1
https://gitee.com/thinkgem/jeesite4.git
git@gitee.com:thinkgem/jeesite4.git
thinkgem
jeesite4
JeeSite 4.x

Help Search