Dragon_dance_
Dragon_dance_
采纳率100%
2020-04-30 16:22 阅读 843
已采纳

来自萌新的求助-attempted to return null from a method with a primitive return type (int)如何解决?

Mapper method 'com.min.atcrowdfunding.manager.dao.RoleMapper.insertRolePermission attempted to return null from a method with a primitive return type (int).
这个我在XML里加resultType="int"也没有用····还是这个错,啥问题那

public int saveRolePermissionRelationship(Integer roleid, Data datas) {

    roleMapper.deleteRolePermissionRelationship(roleid);

    int totalCount = 0;
    List<Integer> ids = datas.getIds();
    for (Integer permissionid : ids) {
        RolePermission rp = new RolePermission();
        rp.setRoleid(roleid);
        rp.setPermissionid(permissionid);
        int count = roleMapper.insertRolePermission(rp);
        totalCount += count;
    }

    return totalCount;
}
以上是在实现类里写的,下面是Mapper加入的方法

void deleteRolePermissionRelationship(Integer roleid);
int insertRolePermission(RolePermission rp);
下面是XML里的SQL语句
<select id="insertRolePermission">
insert into t_role_permission(roleid,permissionid) values(#{roleid},#{permissionid})

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    gf0515 Fatal Error 2020-04-30 16:44
    <select id="insertRolePermission">
    

    改成

    <insert id="insertRolePermission">
    

    试试看

    点赞 评论 复制链接分享

相关推荐