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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM