org.apache.ibatis.binding.BindingException: Mapper method 'com.insight.hr.Call.mapper.CallMapper.SelectCallNum attempted to return null from a method with a primitive return type (int).
sql:
<select id="SelectCallNum" resultType="int">
select callnum from call_table
where callOfPassive =#{userid} order by callnum desc
</select>
执行结果 :(此记录的该字段未赋值)、(查询出的结果为空,无数据/空表)
解决办法:返回callnum时进行判断,使用nvl函数:
select nvl(callnum,1) as callnum from call_table
where callOfPassive =#{userid} order by callnum desc
补充:nvl函数和nvl2函数
NVL(E1, E2)的功能为:如果E1为NULL,则函数返回E2,否则返回E1本身。
NVL2(E1, E2, E3)的功能为:如果E1为NULL,则函数返回E3,若E1不为null,则返回E2。