【异常】mybatis-plus:分页TooManyResultsException: Expected one result (or null) to be returned by selectOn
当mybatis-plus所提供的接口不能满足业务需要的时候,需要自定义sql语句,有时候会用到分页查询,当使用/*** 分页查询我的评论** @param uid* @return*/IPage<MyCommentDto> queryMyComment( @Param("uid") Long uid,Page...
·
当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);
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)