首页 > 其他 > 详细

mybatis-plus IPage分页多参数查询踩坑

时间:2021-02-06 15:50:51      阅读:361      评论:0      收藏:0      [点我收藏+]

1.Mapper

IPage<Entity> findById(@Param("id") Integer id, Page<Entity> page );

2.Mapper.xml

<select id="findById" resultType="com.xxx.Entity" parameterType="com.xxx.Entity">
    select
    <include refid="invalid"/>
    from table_name
    where
    id = #{id}
</select>

3. TooManyResultsException

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 10

问题解决

mybatis-plus 中page参数不在第一个位置,返回的结果集接收对象不被认为是一个集合,而放在第一位就没有问题。所以正确的写法是

IPage<Entity> findById(Page<Entity> page, @Param("id") Integer id);

mybatis-plus IPage分页多参数查询踩坑

原文:https://www.cnblogs.com/cchilei/p/14381312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!