异常报错:
org.apache.ibatis.binding.BindingException: Mapper method 'XXXMapper.XXXMethod attempted' to return null from a method with a primitive return type (int)
SQL语句:
<select id = "XXXMethod" resultType = "int">
select id from emp where emp_name = #{empName}
</select>
原因:SQL查询的返回值为null
,但是方法的返回值为int
,int
无法接收null
值,因此报错
解决方案:返回值由int
改为integer
编程规范:所有Mapper方法的返回值一律使用对象,防止出现方法返回值为Null时,出现的异常状况