mybatis mysql count(*) 返回结果为null的解决

来源:互联网 发布:matebook x ubuntu 编辑:程序博客网 时间:2024/05/21 09:17

具体错误信息:

org.apache.ibatis.binding.BindingException: Mapper method 'com.xx.xx.xx.xx.xx.getCount attempted to return null from a method with a primitive return type (int). 


定义的Integer,怎么会返回null呢?mysql版本问题?

不是这样的,仔细检查sql语句,加了group by ,那么count(*)在检索后如果没有任何数据,那就会返回null。

解决:

SELECT COUNT(*) FROM (   <!-- 原来的sql -->) t

再试下,ok

1 1
原创粉丝点击