PageHelper paging plug-in

Posted by robwilson on Sun, 17 May 2020 17:35:48 +0200

<dependency>
              <groupId>com.github.pagehelper</groupId>
              <artifactId>pagehelper</artifactId>
            <version>5.1.8</version>
        </dependency>
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
            <version>1.2.10</version>
        </dependency>
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.10</version>
        </dependency>

Dependency to be introduced for mybatis paging

Recently, I saw that pageHelper, a paging plug-in, has efficiency problems

Like me, most people are attracted by the super convenient paging operation when they first contact PageHelper

How convenient is it?

public PageInfo querySharePage(QueryObject qo) { PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize()); List<ShareTrainHh> shareList = trainHhMapper.selectAll(); return new PageInfo(shareList); } 

A common paging function, which only needs three sentences of code from beginning to end

Profile:

If you use a single data source, you can configure the following in the configuration file:
pagehelper:
  helperDialect: mysql
  reasonable: false
  supportMethodsArguments: true
  params: count=countSql

//If you use multiple data sources, you need to modify the pagehelper configuration item as follows
pagehelper:
#  helperDialect: mysql
  reasonable: false
  supportMethodsArguments: true
  params: count=countSql
# The default is false. When it is true, the appropriate database will be automatically verified 
  auto-dialect: true
   # This must be added. Otherwise, mysql and SQL Server Pages can only use one page, and the other will report an error. After adding, both database pages can be used
  auto-runtime-dialect: true

 

But!

Don't use a table with a larger amount of data!



Author: Utopia under candle fire
Reference: https://www.jianshu.com/p/88d1eca40271


Topics: github MySQL Spring Database