mybatis deal with empty result list. 查询结果为empty。

List<User> resultList = (List<User>)sqlSession.select("statementId");


<select id="statementId" resultType="User">
   select * from user where id > 100
</select>

assume that the above SQL return no rows (i.e. there is no id greater than 100).

The variable resultList will then be an empty List, but I want it to be null instead. How can I do that?


结果:

      如果没有查询到结果,将会返回一个empty的r esultlist,然后resultlist 的size 是0 而不是null.

你可能感兴趣的:(mybaits,size=0,返回list为empty)