• 在mybatis中分组之后查询每组的数量时,如果没有数据会返回null
      例如在Mapper接口中这样声明: ```java //mapper中定义的接口 int getGroupCount();

    //对应的mybatis中的SQL语句

    1. 如果表里面没有数据,这里就会报异常:**attempted to return null from a method with a primitive return type (int)**<br />而且明显在mapper中写的接口是想获取分组后的总条数,而不是分组后的每组的条数。所以这样写SQL是不对的。<br />应该这样写:
    2. ```xml
    3. <select id="getGroupCount" resultType="int">
    4. select count(*) from (select name from user group by name ) as t
    5. </select>