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);