baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.12k stars 4.26k forks source link

用同一个对象作为分页查询参数,后执行的分页查询结果会覆盖前一个的查询结果 #6308

Closed Jenyow closed 2 weeks ago

Jenyow commented 2 weeks ago

当前使用版本 3.4.1

当前环境信息 Java8 + kingbase

描述bug现象 类继承 Page 作为分页查询的请求参数。用同一个对象作为分页查询参数,后执行的分页查询结果会覆盖前一个的查询结果。

提供问题复现步骤

public class Table1SearchParam extends Page<Table1> {
  ...
}

public interface Table1DAO extends BaseMapper<Table1> {

    IPage<Table1Dto> listHistoryTaskByParams(@Param("params") Table1SearchParam params);

    IPage<Table1Dto> listRunTaskByParams(@Param("params") Table1SearchParam params);

}

@Service
public class Table1ServiceImpl extends ServiceImpl<Table1DAO, Table1> implements Table1Service {

    @Override
    public IPage<Table1Dto> listHistoryTaskByParams(Table1SearchParam params) {
        return baseMapper.listHistoryTaskByParams(params);
    }

    @Override
    public IPage<Table1Dto> listRunTaskByParams(Table1SearchParam params) {
        return baseMapper.listRunTaskByParams(params);
    }

    public IPage<Table1Dto> queryWorkflowItems(Table1SearchParam params) {
        IPage<Table1Dto> historyTaskPage = listHistoryTaskByParams(params);
        IPage<Table1Dto> runTaskPage = listRunTaskByParams(params);
        ...
    }
}

runTaskPage 的值会覆盖 historyTaskPage 的值

miemieYaho commented 2 weeks ago

就这样的

Jenyow commented 2 weeks ago

就这样的

入参不应该作为出参。明明是两个独立的查询,结果后面的影响了前面的,你认为这合理?

miemieYaho commented 2 weeks ago

就这么设计的,出参是interface那就不能new那就出参只能是list,你要接受出参是ipage那就只能这样

Jenyow commented 2 weeks ago

就这么设计的,出参是interface那就不能new那就出参只能是list,你要接受出参是ipage那就只能这样

new的不是interface,返回的难道不是interface的实现类的实例?实现类不能new?出参不用IPage,用Page就正常,是这个意思?

miemieYaho commented 2 weeks ago

返回哪个实现类?a想要classA,b想要classb你怎么处理? 返回Ipage就是为了不框死了,而且文档已经说明了入参=出参