当mybatis-plus所提供的接口不能满足业务需要的时候,需要自定义sql语句,有时候会用到分页查询,当使用
/**
* 分页查询我的评论
*
* @param uid
* @return
*/
IPage<MyCommentDto> queryMyComment( @Param("uid") Long uid,Page<MyCommentDto> page);
这个mapper接口去分页的时候,会出现如下错误
nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 20] with root cause org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 20
我们需要将page放到参数的第一个位置,就能解决该问题。如下:
/**
* 分页查询我的评论
*
* @param uid
* @return
*/
IPage<MyCommentDto> queryMyComment(Page<MyCommentDto> page, @Param("uid") Long uid);