您的位置:首页 > 其它

关于attempted to return null from a method with a primitive return type (int).报错解决方案

2017-11-16 18:45 1056 查看
使用mybatis返回int类型时

<select id="queryPerfTarget" resultType="java.lang.Integer" >
SELECT sum(perf_target) from subject
</select>


项目总是报错

org.apache.ibatis.binding.BindingException: Mapper method 'queryPerfTarget' (interface com.****.workbench.subject.dao.SubjectMapper) attempted to return null from a method with a primitive return type (int).


解决方案:(当查询出来为空时,给赋值一个默认值:MySQL使用函数ifnull())

<select id="queryPerfTarget" resultType="java.lang.Integer" >
SELECT IFNULL(sum(perf_target),0) from subject
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐