代码
Page<CouponInfo> page = new Page<>(1, -1);
CouponInfo couponInfo1 = new CouponInfo();
couponInfo1.setId(1630503086041903106L);
Page<CouponInfo> couponInfoPage = couponInfoMapper.selectPageList(couponInfo1, page);
Page<CouponInfo> couponInfoPage1 = couponInfoMapper.selectPageList2(couponInfo1, page);
couponInfoPage和couponInfoPage1
借鉴大佬文章https://zhuanlan.zhihu.com/p/550164886
com.baomidou.mybatisplus.core.override.MybatisMapperMethod#execute
85行executeForIPage真正执行,其中args则是入参Mapper的Page,由于Page是同一个对象,则返回塞入同一个对象
// TODO 这里下面改了
if (IPage.class.isAssignableFrom(method.getReturnType())) {
result = executeForIPage(sqlSession, args);
}
private <E> Object executeForIPage(SqlSession sqlSession, Object[] args) {
IPage<E> result = null;
for (Object arg : args) {
if (arg instanceof IPage) {
result = (IPage<E>) arg;
break;
}
}
Assert.notNull(result, "can't found IPage for args!");
Object param = method.convertArgsToSqlCommandParam(args);
List<E> list = sqlSession.selectList(command.getName(), param);
result.setRecords(list);
return result;
}
修复===>
Page<CouponInfo> page = new Page<>(1, 10);
Page<CouponInfo> page2= new Page<>(1, 10);
// page=null;
CouponInfo couponInfo1 = new CouponInfo();
couponInfo1.setId(1630503086041903106L);
Page<CouponInfo> couponInfoPage = couponInfoMapper.selectPageList(couponInfo1, page);
Page<CouponInfo> couponInfoPage1 = couponInfoMapper.selectPageList2(couponInfo1, page2);
标签:MybatisPlus,args,公用,page,result,couponInfo1,new,Page
From: https://www.cnblogs.com/wsyphaha/p/18211504