Repolode
pagehelper-org

pagehelper-org/Mybatis-PageHelper

A MyBatis plugin that adds physical pagination to queries, generating database-specific LIMIT or equivalent SQL for many databases.

Stars
12,316
Forks
3,073
Open issues
66
Last commit
4 days ago

What is it?

PageHelper is a pagination plugin for MyBatis, the Java persistence framework. Instead of writing paging SQL by hand, a developer calls a static method before a query, and the plugin rewrites the SQL so that only the requested page of rows is fetched from the database. It supports single-table and complex multi-table queries.

The plugin detects the database dialect automatically from the JDBC URL and covers a long list of databases, including MySQL, PostgreSQL, Oracle, SQL Server, DB2, H2, and several domestic Chinese databases such as Dameng, Kingbase and openGauss. Custom dialects can be registered through a dialectAlias setting. Connection pools such as Hikari, Druid, Tomcat JDBC, DBCP and C3P0 are also recognized for dialect negotiation.

PageHelper is distributed as a Maven artifact and requires jsqlparser on the classpath. Version 6 requires JDK 8 or later, while version 5 supports JDK 6. A separate Spring Boot starter is maintained for Spring Boot projects.

Key features

  • 01Rewrites queries to fetch only one page of rows at the database level.
  • 02Detects the database dialect automatically from the JDBC URL.
  • 03Supports a wide range of databases, including several Chinese domestic ones.
  • 04Allows custom dialects through the dialectAlias setting.
  • 05Provides an Executor-level QueryInterceptor extension point.

Use cases

  • Adding paginated list endpoints to a Java service that uses MyBatis.
  • Paging through complex multi-table queries without hand-written LIMIT clauses.
  • Running MyBatis against domestic Chinese databases such as Dameng or Kingbase.

Quick start

  1. 1

    Add the pagehelper Maven dependency (use the latest version) to pom.xml

  2. 2

    Read the usage guide for configuration and usage details

Things to know

  • Documentation and README are primarily in Chinese, with the English version in a separate file.
  • Requires a MyBatis setup and the jsqlparser library on the classpath.

In collections

Topics

#mybatis#pagination#java#jdbc#orm#sql#spring-boot#mybatis-plugin

FAQ

What is Mybatis-PageHelper?
A MyBatis plugin that adds physical pagination to queries, generating database-specific LIMIT or equivalent SQL for many databases. PageHelper is a pagination plugin for MyBatis, the Java persistence framework. Instead of writing paging SQL by hand, a developer calls a static method before a query, and the plugin rewrites the SQL so that only the requested page of rows is fetched from the database. It supports single-table and complex multi-table queries.
Is Mybatis-PageHelper free to use? What license does it have?
Mybatis-PageHelper is open source under the MIT license. Check the license terms before using it in commercial products.
Is Mybatis-PageHelper still maintained?
Actively maintained. The last commit to Mybatis-PageHelper was on Nov 3, 2026.
What can I use Mybatis-PageHelper for?
Adding paginated list endpoints to a Java service that uses MyBatis. Paging through complex multi-table queries without hand-written LIMIT clauses. Running MyBatis against domestic Chinese databases such as Dameng or Kingbase.
How do I install Mybatis-PageHelper?
Add the pagehelper Maven dependency (use the latest version) to pom.xml Read the usage guide for configuration and usage details
Where can I get Mybatis-PageHelper?
The source code and installation instructions are on GitHub: https://github.com/pagehelper-org/Mybatis-PageHelper

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects