首页 > 其他分享 >MybatisPlus公用Page导致同对象返回

MybatisPlus公用Page导致同对象返回

时间:2024-05-24 18:18:20浏览次数:15  
标签:MybatisPlus args 公用 page result couponInfo1 new Page

代码

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

1c35106b95343cc4a86b9106ffb1b7c

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

相关文章

  • MybatisPlus
    Mybatis-plus:Mybatis增强工具,只做增强,不作改变,简化开发,提高效率。Mybatis-plus特点:无侵入:Mybatis-Plus在Mybatis的基础上进行扩展,只做增强不做改变,引入Mybatis-Plus不会对现有的Mybatis构架产生任何影响,而且MP支持所有Mybatis原生的特性依赖少:仅仅依赖Myba......
  • PageOffice国产版用强制留痕模式在线编辑word文件
    #PageOffice国产版强制留痕模式编辑查看本示例演示效果本示例关键代码的编写位置Vue+Springboot注意PageOffice国产版支持统信UOS、银河麒麟等操作系统本文中展示的代码均为关键代码,复制粘贴到您的项目中,按照实际的情况,例如文档路径,用户名等做适当修改即可使用。Word中的“......
  • QPrinter、QPrinterInfo、QPageLayout
    QPrinter一、描述QPrinter类是在打印机上绘制的绘制设备,其使用方式与其他绘图设备(如QWidget和QPixmap)几乎完全相同。提供了一组附加功能来管理特定于设备的功能,例如方向、分辨率、在生成文档时逐步浏览文档中的页面。在无效打印机上设置参数(如纸张尺寸和分辨率)是未定义的。......
  • MIT 6.S081 学习笔记 -- page tables
    Chapter3Pagetable1.FromUserperspetive,howVAmapstoPA?lab1:printpagetableforpid==1, PR: https://github.com/nipperhou/xv6-riscv/commit/eb8e0008c019cfa0f3687989a90a63a7d45bde6fOutput: ```xv6kernelisbootingtrampoline:0x00000000800070......
  • DrissionPage对浏览器的一些配置
    DrissionPage对浏览器的一些配置ele=page.ele('中国日报')#查找text包含“中国日报”的元素page.wait.title_change('连铸坯表面纵裂纹的形成与控制研究现状')#等待title变化出现目标文本importtimeimportrandomfromDrissionPageimportChromiumPage,ChromiumO......
  • 容器内存可观测性新视角:WorkingSet 与 PageCache 监控
    作者:行疾、尝君、佑祎、六滔容器工作内存WorkingSet 概念介绍在Kubernetes场景,容器内存实时使用量统计(PodMemory),由WorkingSet工作内存(缩写WSS)来表示。WorkingSet这个指标概念,是由cadvisor为容器场景定义的。工作内存WorkingSet也是Kubernetes的调度决策判断内......
  • 国产linux系统(银河麒麟,统信uos)使用 PageOffice 国产版在线动态填充 word 文件
    PageOffice国产版:支持信创系统,支持银河麒麟V10和统信UOS,支持X86(intel、兆芯、海光等)、ARM(飞腾、鲲鹏、麒麟等)芯片架构。在实际的Word文档开发中,经常需要自动填充数据到Word模板中,以生成动态的Word文档。例如,我们可以根据数据库表中已保存的个人信息,设计好一个简历模板docx文件,......
  • How to redirect to a specific web page after sign out from Entra ID
    HowtoredirecttoaspecificwebpageaftersignoutfromEntraIDWithsomemorediggingIfoundthebelowchangesresultedinasuccessfulredirecttoapageofmychoosing.Ifoundthatifthe SignedOutCallbackPath issettoanythingotherthan /signo......
  • mybatisPlus多数据源的使用&使用 lambdaQuery 导致多数据源失效
    依赖<dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version>3.5.2</version></dependency>配置文件:spr......
  • mybatis-plus pageHelper 合理化配置
    mybatis分页设置//自定义分页拦截器importcom.baomidou.mybatisplus.core.metadata.IPage;importcom.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;publicclassCustomPaginationInterceptorextendsPaginationInnerInterceptor{@......