(Mybatis)attempted to return null from a method with a primitive return type (int)

缺乏、安全感 2021-12-17 01:04 676阅读 0赞

问题描述

执行sql语句执行更新语句时,后台直接报错了,报错信息如下:
在这里插入图片描述
attempted to return null from a method with a primitive return type (int)

解决方法

是因为Mybatis的中的返回值类型写错了,应该使用包装类型而不是基本类型,将int改为Integer即可

  1. @Select(" update tb_customer_tags a set a.count =count+1 where customerid = #{customerid} and tagid = #{tagid} ")
  2. int updateByCustomeridAndTagid(@Param("customerid") String customerid, @Param("tagid") String tagid);

改为

  1. @Select(" update tb_customer_tags a set a.count =count+1 where customerid = #{customerid} and tagid = #{tagid} ")
  2. Integer updateByCustomeridAndTagid(@Param("customerid") String customerid, @Param("tagid") String tagid);

发表评论

表情:
评论列表 (有 0 条评论,676人围观)

还没有评论,来说两句吧...

相关阅读