From 8961063ccaebbcb71e3ea627ab90a8c25bcdd75b Mon Sep 17 00:00:00 2001 From: Rui Date: Sun, 5 Nov 2023 11:45:09 +0800 Subject: [PATCH] =?UTF-8?q?PageHelper=206=20=E5=8F=91=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81jdk8+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 48 ++++-- README_en.md | 52 +++++- README_zh.md | 160 ------------------ pom.xml | 4 +- .../java/com/github/pagehelper/PageInfo.java | 2 +- wikis/en/Changelog.md | 28 +++ wikis/zh/Changelog.md | 20 +++ 7 files changed, 130 insertions(+), 184 deletions(-) delete mode 100644 README_zh.md diff --git a/README.md b/README.md index 043e975e..0bb5c689 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,6 @@ 想要使用分页插件?请看[如何使用分页插件](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md)。 -## 新增 JavaDoc 文档 - -文档地址:https://apidoc.gitee.com/free/Mybatis_PageHelper - -Method API: https://apidoc.gitee.com/free/Mybatis_PageHelper/com/github/pagehelper/page/PageMethod.html - ## 《MyBatis 从入门到精通》 ![MyBatis 从入门到精通](https://github.com/mybatis-book/book/raw/master/book.png) @@ -31,6 +25,10 @@ GitHub项目:https://github.com/mybatis-book/book ## 支持 [MyBatis 3.1.0+](https://github.com/mybatis/mybatis-3) +## PageHelper 6 支持 jdk8+ + +## PageHelper 5 支持 jdk6+ + ## 物理分页 该插件目前支持以下数据库的物理分页 [PageAutoDialect](src/main/java/com/github/pagehelper/page/PageAutoDialect.java): @@ -41,19 +39,26 @@ static { registerDialectAlias("hsqldb",HsqldbDialect.class); registerDialectAlias("h2",HsqldbDialect.class); registerDialectAlias("phoenix",HsqldbDialect.class); + registerDialectAlias("postgresql",PostgreSqlDialect.class); + registerDialectAlias("mysql",MySqlDialect.class); registerDialectAlias("mariadb",MySqlDialect.class); registerDialectAlias("sqlite",MySqlDialect.class); + registerDialectAlias("herddb",HerdDBDialect.class); + registerDialectAlias("oracle",OracleDialect.class); registerDialectAlias("oracle9i",Oracle9iDialect.class); registerDialectAlias("db2",Db2Dialect.class); + registerDialectAlias("as400",AS400Dialect.class); registerDialectAlias("informix",InformixDialect.class); //解决 informix-sqli #129,仍然保留上面的 registerDialectAlias("informix-sqli",InformixDialect.class); + registerDialectAlias("sqlserver",SqlServerDialect.class); registerDialectAlias("sqlserver2012",SqlServer2012Dialect.class); + registerDialectAlias("derby",SqlServer2012Dialect.class); //达梦数据库,https://github.com/mybatis-book/book/issues/43 registerDialectAlias("dm",OracleDialect.class); @@ -66,8 +71,28 @@ static { registerDialectAlias("highgo",HsqldbDialect.class); //虚谷数据库 registerDialectAlias("xugu",HsqldbDialect.class); + registerDialectAlias("impala",HsqldbDialect.class); + registerDialectAlias("firebirdsql",FirebirdDialect.class); //人大金仓数据库 registerDialectAlias("kingbase",PostgreSqlDialect.class); + // 人大金仓新版本kingbase8 + registerDialectAlias("kingbase8",PostgreSqlDialect.class); + //行云数据库 + registerDialectAlias("xcloud",CirroDataDialect.class); + + //openGauss数据库 + registerDialectAlias("opengauss",PostgreSqlDialect.class); + + //注册 AutoDialect + //想要实现和以前版本相同的效果时,可以配置 autoDialectClass=old + registerAutoDialectAlias("old",DefaultAutoDialect.class); + registerAutoDialectAlias("hikari",HikariAutoDialect.class); + registerAutoDialectAlias("druid",DruidAutoDialect.class); + registerAutoDialectAlias("tomcat-jdbc",TomcatAutoDialect.class); + registerAutoDialectAlias("dbcp",DbcpAutoDialect.class); + registerAutoDialectAlias("c3p0",C3P0AutoDialect.class); + //不配置时,默认使用 DataSourceNegotiationAutoDialect + registerAutoDialectAlias("default",DataSourceNegotiationAutoDialect.class); } ``` @@ -77,9 +102,9 @@ static { > >```xml > -> +> > -> +> > >``` @@ -87,10 +112,6 @@ static { [Executor 拦截器高级教程 - QueryInterceptor 规范](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Interceptor.md) -## 分页插件 5.0 - -由于分页插件 5.0 版本和 4.2.x 实现完全不同,所以 master 分支为 5.x 版本,4.2 作为一个分支存在,如果有针对 4.2 的 PR,请注意提交到分支版本。 - ## 集成 使用 PageHelper 你只需要在 classpath @@ -128,8 +149,7 @@ static { ## 提交 BUG -- [提交到 github](https://github.com/pagehelper/Mybatis-PageHelper/issues/new) -- [提交到 gitosc](http://git.oschina.net/free/Mybatis_PageHelper/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) +https://github.com/pagehelper/Mybatis-PageHelper/issues/new ## 项目的发展离不开你的支持 diff --git a/README_en.md b/README_en.md index 8eb5cbfb..4994e892 100644 --- a/README_en.md +++ b/README_en.md @@ -37,6 +37,10 @@ GitHub:https://github.com/mybatis-book/book ## Support [MyBatis 3.1.0+](https://github.com/mybatis/mybatis-3) +## PageHelper 6 Support jdk8+ + +## PageHelper 5 Support jdk6+ + ## Physical Paging PageHelper supports the following @@ -44,23 +48,30 @@ databases [PageAutoDialect](src/main/java/com/github/pagehelper/page/PageAutoDia ```java static { - //register aliass + //register alias registerDialectAlias("hsqldb",HsqldbDialect.class); registerDialectAlias("h2",HsqldbDialect.class); registerDialectAlias("phoenix",HsqldbDialect.class); + registerDialectAlias("postgresql",PostgreSqlDialect.class); + registerDialectAlias("mysql",MySqlDialect.class); registerDialectAlias("mariadb",MySqlDialect.class); registerDialectAlias("sqlite",MySqlDialect.class); + registerDialectAlias("herddb",HerdDBDialect.class); + registerDialectAlias("oracle",OracleDialect.class); registerDialectAlias("oracle9i",Oracle9iDialect.class); registerDialectAlias("db2",Db2Dialect.class); + registerDialectAlias("as400",AS400Dialect.class); registerDialectAlias("informix",InformixDialect.class); - //解决 informix-sqli #129,仍然保留上面的 + //Solve informix-sqli #129, still keep the above registerDialectAlias("informix-sqli",InformixDialect.class); + registerDialectAlias("sqlserver",SqlServerDialect.class); registerDialectAlias("sqlserver2012",SqlServer2012Dialect.class); + registerDialectAlias("derby",SqlServer2012Dialect.class); //达梦数据库,https://github.com/mybatis-book/book/issues/43 registerDialectAlias("dm",OracleDialect.class); @@ -73,10 +84,28 @@ static { registerDialectAlias("highgo",HsqldbDialect.class); //虚谷数据库 registerDialectAlias("xugu",HsqldbDialect.class); + registerDialectAlias("impala",HsqldbDialect.class); + registerDialectAlias("firebirdsql",FirebirdDialect.class); //人大金仓数据库 registerDialectAlias("kingbase",PostgreSqlDialect.class); - //华为openGauss数据库 + // 人大金仓新版本kingbase8 + registerDialectAlias("kingbase8",PostgreSqlDialect.class); + //行云数据库 + registerDialectAlias("xcloud",CirroDataDialect.class); + + //openGauss数据库 registerDialectAlias("opengauss",PostgreSqlDialect.class); + + //注册 AutoDialect + //If you want to achieve the same effect as the previous version, you can configure it autoDialectClass=old + registerAutoDialectAlias("old",DefaultAutoDialect.class); + registerAutoDialectAlias("hikari",HikariAutoDialect.class); + registerAutoDialectAlias("druid",DruidAutoDialect.class); + registerAutoDialectAlias("tomcat-jdbc",TomcatAutoDialect.class); + registerAutoDialectAlias("dbcp",DbcpAutoDialect.class); + registerAutoDialectAlias("c3p0",C3P0AutoDialect.class); + //If not configured, it is used by default DataSourceNegotiationAutoDialect + registerAutoDialectAlias("default",DataSourceNegotiationAutoDialect.class); } ``` @@ -89,9 +118,9 @@ static { > >```xml > -> +> > -> +> > >``` @@ -135,8 +164,7 @@ the [pagehelper-spring-boot-starter](https://github.com/pagehelper/pagehelper-sp ## Submit BUG -- [Submit to github](https://github.com/pagehelper/Mybatis-PageHelper/issues/new) -- [Submit to gitosc](http://git.oschina.net/free/Mybatis_PageHelper/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) +https://github.com/pagehelper/Mybatis-PageHelper/issues/new ## Thank you for your support @@ -157,3 +185,13 @@ Email: abel533@gmail.com PageHelper on github:https://github.com/pagehelper/Mybatis-PageHelper PageHelper on gitosc:http://git.oschina.net/free/Mybatis_PageHelper + +## MyBatis-3 + +- Project:https://github.com/mybatis/mybatis-3 +- Document:https://mybatis.org/mybatis-3/index.html + +MyBatis 专栏: + +- [MyBatis Sample](http://blog.csdn.net/column/details/mybatis-sample.html) +- [MyBatis QA](http://blog.csdn.net/column/details/mybatisqa.html) diff --git a/README_zh.md b/README_zh.md deleted file mode 100644 index e020af5c..00000000 --- a/README_zh.md +++ /dev/null @@ -1,160 +0,0 @@ -![MyBatis Pagination - PageHelper](logo.png) -# MyBatis 分页插件 - PageHelper - -[![Build Status](https://travis-ci.org/pagehelper/Mybatis-PageHelper.svg?branch=master)](https://travis-ci.org/pagehelper/Mybatis-PageHelper) -[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.github.pagehelper/pagehelper/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.pagehelper/pagehelper) - -[English](README_en.md) - -如果你也在用 MyBatis,建议尝试该分页插件,这一定是最方便使用的分页插件。 - -分页插件支持任何复杂的单表、多表分页,部分特殊情况请看[重要提示](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Important.md)。 - -想要使用分页插件?请看[如何使用分页插件](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md)。 - -## 新增 JavaDoc 文档 - -文档地址:https://apidoc.gitee.com/free/Mybatis_PageHelper - -Method API: https://apidoc.gitee.com/free/Mybatis_PageHelper/com/github/pagehelper/page/PageMethod.html - -## 《MyBatis 从入门到精通》 - -![MyBatis 从入门到精通](https://github.com/mybatis-book/book/raw/master/book.png) - -[京东](https://item.jd.com/12103309.html) ,[当当](http://product.dangdang.com/25098208.html) ,[亚马逊](https://www.amazon.cn/MyBatis从入门到精通-刘增辉/dp/B072RC11DM/ref=sr_1_18?ie=UTF8&qid=1498007125&sr=8-18&keywords=mybatis) - -CSDN博客:http://blog.csdn.net/isea533/article/details/73555400 - -GitHub项目:https://github.com/mybatis-book/book - -## 支持 [MyBatis 3.1.0+](https://github.com/mybatis/mybatis-3) -## 物理分页 - -该插件目前支持以下数据库的物理分页 [PageAutoDialect](src/main/java/com/github/pagehelper/page/PageAutoDialect.java): - -```java -static { - //注册别名 - registerDialectAlias("hsqldb",HsqldbDialect.class); - registerDialectAlias("h2",HsqldbDialect.class); - registerDialectAlias("phoenix",HsqldbDialect.class); - registerDialectAlias("postgresql",PostgreSqlDialect.class); - registerDialectAlias("mysql",MySqlDialect.class); - registerDialectAlias("mariadb",MySqlDialect.class); - registerDialectAlias("sqlite",MySqlDialect.class); - registerDialectAlias("herddb",HerdDBDialect.class); - registerDialectAlias("oracle",OracleDialect.class); - registerDialectAlias("oracle9i",Oracle9iDialect.class); - registerDialectAlias("db2",Db2Dialect.class); - registerDialectAlias("informix",InformixDialect.class); - //解决 informix-sqli #129,仍然保留上面的 - registerDialectAlias("informix-sqli",InformixDialect.class); - registerDialectAlias("sqlserver",SqlServerDialect.class); - registerDialectAlias("sqlserver2012",SqlServer2012Dialect.class); - registerDialectAlias("derby",SqlServer2012Dialect.class); - //达梦数据库,https://github.com/mybatis-book/book/issues/43 - registerDialectAlias("dm",OracleDialect.class); - //阿里云PPAS数据库,https://github.com/pagehelper/Mybatis-PageHelper/issues/281 - registerDialectAlias("edb",OracleDialect.class); - //神通数据库 - registerDialectAlias("oscar",OscarDialect.class); - registerDialectAlias("clickhouse",MySqlDialect.class); - //瀚高数据库 - registerDialectAlias("highgo",HsqldbDialect.class); - //虚谷数据库 - registerDialectAlias("xugu",HsqldbDialect.class); - //人大金仓数据库 - registerDialectAlias("kingbase",PostgreSqlDialect.class); - //华为openGauss数据库 - registerDialectAlias("opengauss",PostgreSqlDialect.class); - } -``` - ->如果你使用的数据库不在这个列表时,你可以配置 `dialectAlias` 参数。 -> ->这个参数允许配置自定义实现的别名,可以用于根据 JDBCURL 自动获取对应实现,允许通过此种方式覆盖已有的实现,配置示例如(多个配置时使用分号隔开): -> ->```xml -> -> -> -> -> ->``` - -## 使用 [QueryInterceptor 规范](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/src/main/java/com/github/pagehelper/QueryInterceptor.java) -[Executor 拦截器高级教程 - QueryInterceptor 规范](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Interceptor.md) - -## 分页插件 5.0 - -由于分页插件 5.0 版本和 4.2.x 实现完全不同,所以 master 分支为 5.x 版本,4.2 作为一个分支存在,如果有针对 4.2 的 PR,请注意提交到分支版本。 - -## 集成 -使用 PageHelper 你只需要在 classpath 中包含 [pagehelper-x.y.z.jar](http://repo1.maven.org/maven2/com/github/pagehelper/pagehelper/) 和 [jsqlparser-x.y.z.jar](http://repo1.maven.org/maven2/com/github/jsqlparser/jsqlparser/)。 - -> pagehelper 和 jsqlparser 对应关系参考 pom.xml 中的依赖版本。 - -如果你使用 Maven,你只需要在 pom.xml 中添加下面的依赖: - -```xml - - - com.github.pagehelper - pagehelper - 最新版本 - -``` - -如果你使用 Spring Boot 可以参考: [pagehelper-spring-boot-starter](https://github.com/pagehelper/pagehelper-spring-boot) - -[继续查看配置和用法](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md) - -## 文档: - -- [如何使用分页插件](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md) -- [更新日志](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Changelog.md) -- [重要提示](https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Important.md) - -## Spring 集成示例 - -- [集成 Spring 3.x](https://github.com/abel533/Mybatis-Spring/tree/spring3.x) -- [集成 Spring 4.x](https://github.com/abel533/Mybatis-Spring) -- [集成 Spring Boot](https://github.com/abel533/MyBatis-Spring-Boot) - -## 提交 BUG - -- [提交到 github](https://github.com/pagehelper/Mybatis-PageHelper/issues/new) -- [提交到 gitosc](http://git.oschina.net/free/Mybatis_PageHelper/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) - -## 项目的发展离不开你的支持 - -### 请作者喝杯咖啡吧! - - - - - -## 作者信息 - -网站:https://mybatis.io - -作者博客:http://blog.csdn.net/isea533 - -作者邮箱: abel533@gmail.com - -如需加群,请通过 http://mybatis.io 首页按钮加群。 - -本项目在 github 的项目地址:https://github.com/pagehelper/Mybatis-PageHelper - -本项目在 gitosc 的项目地址:http://git.oschina.net/free/Mybatis_PageHelper - -## MyBatis-3 - -- 项目:https://github.com/mybatis/mybatis-3 -- 文档:http://mybatis.github.io/mybatis-3/zh/index.html - -MyBatis 专栏: - -- [MyBatis示例](http://blog.csdn.net/column/details/mybatis-sample.html) -- [MyBatis问题集](http://blog.csdn.net/column/details/mybatisqa.html) diff --git a/pom.xml b/pom.xml index 8c17e5d8..719fb744 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,10 @@ com.github.pagehelper pagehelper - 6.0.0-SNAPSHOT + 6.0.0 jar - pagehelper 5 + pagehelper 6 Mybatis Pagination Plugin https://github.com/pagehelper/Mybatis-PageHelper diff --git a/src/main/java/com/github/pagehelper/PageInfo.java b/src/main/java/com/github/pagehelper/PageInfo.java index 42a8148e..3fe9e741 100644 --- a/src/main/java/com/github/pagehelper/PageInfo.java +++ b/src/main/java/com/github/pagehelper/PageInfo.java @@ -259,7 +259,7 @@ private void judgePageBoudary() { * @param 目标类型 * @return 转换了对象类型的包装结果 */ - private PageInfo convert(Page.Function function) { + public PageInfo convert(Page.Function function) { List list = new ArrayList(this.list.size()); for (T t : this.list) { list.add(function.apply(t)); diff --git a/wikis/en/Changelog.md b/wikis/en/Changelog.md index a0526de3..99a855cb 100644 --- a/wikis/en/Changelog.md +++ b/wikis/en/Changelog.md @@ -1,5 +1,33 @@ ## Changelog +### 6.0.0 - 2023-11-05 + +- Based on JDK 8 adaptation, JDK 6 and 7 are not supported from 6.0 onwards, and 5.x versions can be used if necessary +- Added asynchronous count support, configure `asyncCount` globally, default `false`,single activation + by `PageHelper.startPage(1, 10).enableAsyncCount()`; + Asynchronous queries are performed using independent connections (transactions), + and it is not suitable to enable asynchronous queries when the query is affected by addition, deletion, and + modification operations. closed #334 +- JSqlParser opens `parser.withSquareBracketQuotation(true)` by default and supports SqlServer `[]` +- feat: A new method for data object conversion has been added to the `PageInfo`, + method: ` PageInfo convert(Page.Function function)` **by codeke** +- `CountSqlParser` is changed to an interface, allowing the `countSqlParser` parameter to be replaced with your own + implementation, which is supported #772 +- `dialectAlias` supports simplified configurations, e.g. `dm=oracle;oracle=oracle9i`, a direct reference to the current + abbreviation, without writing the full name of the class +- `countColumn`add injection detection, fixed #686 +- Add the `PageParam` class, which does not embed objects (will affect the use), if you want to use, you can inherit the + object,closed #562 +- All exception messages have been changed to English +- open `setLocalPage` method, support #771 +- Solve the problem of handling order by error when `sqlserver` with union sql parsing,fixed #768 +- Optimized the total logic to solve the problem that the query is not pagination and the order by is invalid. fixed + #641 +- Modify the dialect instantiation logic to ensure that the class is used after the configuration is completed. fixed + #742 +- `dialectAliasMap` change to `LinkedHashMap` type, support matching in configuration order, fixed #758 +- fixed the pagination bug of xingyun database **by maimaitiyaer_bonc** +- ### 5.3.3 - 2023-06-03 - Ignoring unnecessarily generated surefire-report **by java-codehunger** diff --git a/wikis/zh/Changelog.md b/wikis/zh/Changelog.md index 85397a8b..1962af9b 100644 --- a/wikis/zh/Changelog.md +++ b/wikis/zh/Changelog.md @@ -1,5 +1,25 @@ ## 更新日志 +### 6.0.0 - 2023-11-05 + +- 基于jdk8适配,6.0开始不支持jdk6和7,如果有需要可以使用5.x版本 +- 增加异步count支持,全局配置`asyncCount`,默认`false`,单次设置:`PageHelper.startPage(1, 10).enableAsyncCount()`; + 异步使用独立连接(事务)查询,有增删改操作影响查询时不适合开启异步查询。closed #334 +- JSqlParser默认开启 `parser.withSquareBracketQuotation(true)`,支持 SqlServer `[]` +- feat: 在`PageInfo`类中新增了用以进行数据对象转换的方法 ` PageInfo convert(Page.Function function)` **by + codeke** +- `CountSqlParser`改为接口,允许通过`countSqlParser`参数替换为自己的实现,支持 #772 +- `dialectAlias`支持简化配置,例如`dm=oracle;oracle=oracle9i`,直接引用现在的缩写,不用写类全名 +- `countColumn`添加注入检测,fixed #686 +- 增加`PageParam`类,不内嵌对象(会影响使用),如果想用可以继承该对象,closed #562 +- 所有异常信息改为英文提示 +- 放开 `setLocalPage`,支持 #771 +- 解决`sqlserver`带union sql解析时处理order by错误的问题,fixed #768 +- 优化total逻辑,解决指定不分页查询,同时指定order by时无效的问题,fixed #641 +- 修改 dialect 实例化逻辑,保证类完成配置后使用,fixed #742 +- `dialectAliasMap`改为`LinkedHashMap`,可以按配置顺序进行匹配,fixed #758 +- 行云数据库分页BUG修复 **by maimaitiyaer_bonc** + ### 5.3.3 - 2023-06-03 - Ignoring unnecessarily generated surefire-report **by java-codehunger**