1.Mapper

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

2.Mapper.xml

<select >
    select
    <include ref/>
    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);

相关文章: