问题描述
执行sql语句执行更新语句时,后台直接报错了,报错信息如下:
attempted to return null from a method with a primitive return type (int)
解决方法
是因为Mybatis的中的返回值类型写错了,应该使用包装类型而不是基本类型,将int改为Integer即可
@Select(" update tb_customer_tags a set a.count =count+1 where customerid = #{customerid} and tagid = #{tagid} ")
int updateByCustomeridAndTagid(@Param("customerid") String customerid, @Param("tagid") String tagid);
改为
@Select(" update tb_customer_tags a set a.count =count+1 where customerid = #{customerid} and tagid = #{tagid} ")
Integer updateByCustomeridAndTagid(@Param("customerid") String customerid, @Param("tagid") String tagid);