Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flashvayne/mysql-mybatis-pagination
A lightweight pagination interceptor based on MySQL Dialect "SQL_CALC_FOUND_ROWS"
https://github.com/flashvayne/mysql-mybatis-pagination
mybatis mysql page
Last synced: 21 days ago
JSON representation
A lightweight pagination interceptor based on MySQL Dialect "SQL_CALC_FOUND_ROWS"
- Host: GitHub
- URL: https://github.com/flashvayne/mysql-mybatis-pagination
- Owner: flashvayne
- License: mit
- Created: 2022-01-13T06:51:55.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T07:36:16.000Z (over 2 years ago)
- Last Synced: 2024-11-02T14:51:34.349Z (2 months ago)
- Topics: mybatis, mysql, page
- Language: Java
- Homepage:
- Size: 53.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Maven central](https://maven-badges.herokuapp.com/maven-central/io.github.flashvayne/mysql-mybatis-pagination/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.flashvayne/mysql-mybatis-pagination)
[中文版文档](https://github.com/flashvayne/mysql-mybatis-page/blob/master/README_zh.md)
# mysql-mybatis-pagination
A very lightweight pagination interceptor based on MySQL Dialect "SQL_CALC_FOUND_ROWS & FOUND_ROWS()"
## Usage
1.Load maven dependency.
For SpringBoot project, interceptor will be autowired on startup, no additional configuration required.
```pomio.github.flashvayne
mysql-mybatis-pagination
2.0.0```
2.Use the following code where pagination is required
```java
Page.start(pageNum,pageSize);
List users = userMapper.select();
PageInfo pageInfo = Page.end(users);
logger.info("pageInfo: {}", pageInfo);
```
*Notice:
Pagination only takes effect at the first query after "Page.start()".
Pagination will not be applied to any query executed after line "Page.end()", unless "Page.start()" is called again to start a new paging process.When you are using a thread poll and there is no query was invoked after "Page.start()", notice that invoke "Page.clear()" manually to end current paging process. So that when the current thread is invoked next time,the pagination will not take effect inexplicably.
(Because pagination is using ThreadLocal to take effect)# Author Info
Email: [email protected]Blog: https://vayne.cc