zoukankan      html  css  js  c++  java
  • Shardingjdbc分页 Limit 总是从0开始查询所有数据问题的解决办法

    MyBatis-Plus 分页查询, 老项目中 shardingjdbc 分库分表插件后 分页查询查看sql语句 就是这个样子了

    第一页LIMIT 0,100
    第二页LIMIT 0,200, 
    第三页LIMIT 0,300, 
    总是取的当前0到截止页码的所有数据

    把原有引入的jar 包版本从 3.1.0 降到  3.0.0 问题解决
    <dependency>   
      <groupId>io.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>3.1.0</version>
    </dependency>
    <dependency>
    <groupId>io.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-namespace</artifactId>
       <version>3.1.0</version>
    </dependency>
    <dependency>
    <groupId>io.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>3.0.0</version>
    </dependency>
    <dependency>
    <groupId>io.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-namespace</artifactId>
       <version>3.0.0</version>
    </dependency>

    断点查看源码大概是 3.1.0版本中 Limit 类在拼接改写sql语句的时候把原有 startLimit value 值判断更新为0了,感觉是这个版本的bug




    不过 ,Shardingsphere 插件项目 2020年04月16日已 成为Apache顶级项目,建议用apache 下的新版本

    <!-- https://mvnrepository.com/artifact/org.apache.shardingsphere/sharding-jdbc-core -->
    <dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-core</artifactId>
    <version>4.1.1</version>
    </dependency>

  • 相关阅读:
    学习之路
    c
    为什么正确,还是有点bug?
    1212
    学习呀
    记录一下学习c语言的过程3.26日1
    字符串处理
    二维数组的转置
    一维数组转置
    Mybatis读取数据实战
  • 原文地址:https://www.cnblogs.com/laotan/p/15047726.html
Copyright © 2011-2022 走看看