Releases: pagehelper/Mybatis-PageHelper
5.1.6 - 2018-09-05
5.1.6 - 2018-09-05
- 增加参数 useSqlserver2012,设置为 true 后,使用 sqlserver2012(Dialect) 作为 SqlServer 数据库的默认分页方式,这种情况在动态数据源时方便使用。默认使用的低版本(05,08)分页方式。
- 增加 IPage 接口,目前支持 mybatis 查询方法只有一个参数,并且参数实现 IPage 接口时,如果存在分页参数,就会自动进行分页查询。感谢 moonfruit 两年前的 issue。
- 解决 HashSet 并发问题 fixed #276
- 优化代码结构,精简拦截器代码
5.1.6 - 2018-09-05
- Add the parameter useSqlserver2012, set to true, and use sqlserver2012(Dialect) as the default paging method for SQL Server databases, which is useful in dynamic data sources.
- Add an IPage interface. Currently, there is only one parameter to support the MyBatis query method, and when the parameter implements the IPage interface, paging query will be automatically performed if paging parameters exist. Thanks to moonfruit Issue two years ago.
- fixed # 276 to resolve hashset concurrency issue
- Optimize code structure and streamline interceptor code
5.1.5 - 2018-09-02
5.1.5 - 2018-09-02
- 优化代码,去掉没必要的校验(by lenosp)
- 解决 pageKey 多处理一次的小问题 #268
- 新增 gitee 提供的 javadoc 文档(https://apidoc.gitee.com/free/Mybatis_PageHelper)
- 解决默认反射不带缓存的问题 fixed #275
- 优化mysql ifnull函数导致分页性能问题 (by miaogr)(这个修改最终改成了下面的
aggregateFunctions
) - jsqlparser 升级为 1.2 版本,和 1.0 有不兼容的情况,已经解决。 fixed 273
- 去掉 PageInfo 中存在歧义的 g(s)etFirstPage 和 g(s)etLastPage 两个方法
- 抛出排序时解析失败的异常 fixed #257
- 解决 Spring
<bean>
方式配置时,没有properties
属性时的初始化问题 fixed #26 - 修复Oracle分页会漏查数据的问题 (by muyun12)
- 新增
aggregateFunctions
参数(CountSqlParser
), 允许手动添加聚合函数(影响行数),所以以聚合函数开头的函数,在进行 count 转换时,会套一层。其他函数和列会被替换为 count(0),其中count列可以自己配置。
增加 aggregateFunctions
参数后,和原先最大的区别是,如果存在 select ifnull(xxx, yy) from table ...
,原先的 count 查询是
select count(0) from (select ifnull(xxx, yy) from table ...) temp_count
,现在会区别聚合函数,如果不是聚合函数,就会变成
select count(0) from table ...
。
默认包含的聚合函数前缀如下:
/**
* 聚合函数,以下列函数开头的都认为是聚合函数
*/
private static final Set<String> AGGREGATE_FUNCTIONS = new HashSet<String>(Arrays.asList(
("APPROX_COUNT_DISTINCT," +
"ARRAY_AGG," +
"AVG," +
"BIT_" +
//"BIT_AND," +
//"BIT_OR," +
//"BIT_XOR," +
"BOOL_," +
//"BOOL_AND," +
//"BOOL_OR," +
"CHECKSUM_AGG," +
"COLLECT," +
"CORR," +
//"CORR_," +
//"CORRELATION," +
"COUNT," +
//"COUNT_BIG," +
"COVAR," +
//"COVAR_POP," +
//"COVAR_SAMP," +
//"COVARIANCE," +
//"COVARIANCE_SAMP," +
"CUME_DIST," +
"DENSE_RANK," +
"EVERY," +
"FIRST," +
"GROUP," +
//"GROUP_CONCAT," +
//"GROUP_ID," +
//"GROUPING," +
//"GROUPING," +
//"GROUPING_ID," +
"JSON_," +
//"JSON_AGG," +
//"JSON_ARRAYAGG," +
//"JSON_OBJECT_AGG," +
//"JSON_OBJECTAGG," +
//"JSONB_AGG," +
//"JSONB_OBJECT_AGG," +
"LAST," +
"LISTAGG," +
"MAX," +
"MEDIAN," +
"MIN," +
"PERCENT_," +
//"PERCENT_RANK," +
//"PERCENTILE_CONT," +
//"PERCENTILE_DISC," +
"RANK," +
"REGR_," +
"SELECTIVITY," +
"STATS_," +
//"STATS_BINOMIAL_TEST," +
//"STATS_CROSSTAB," +
//"STATS_F_TEST," +
//"STATS_KS_TEST," +
//"STATS_MODE," +
//"STATS_MW_TEST," +
//"STATS_ONE_WAY_ANOVA," +
//"STATS_T_TEST_*," +
//"STATS_WSR_TEST," +
"STD," +
//"STDDEV," +
//"STDDEV_POP," +
//"STDDEV_SAMP," +
//"STDDEV_SAMP," +
//"STDEV," +
//"STDEVP," +
"STRING_AGG," +
"SUM," +
"SYS_OP_ZONE_ID," +
"SYS_XMLAGG," +
"VAR," +
//"VAR_POP," +
//"VAR_SAMP," +
//"VARIANCE," +
//"VARIANCE_SAMP," +
//"VARP," +
"XMLAGG").split(",")));
5.1.5 - 2018-09-02
- Optimize the code and remove unnecessary checks(by lenosp)
- Solve the small problem of pageKey multi-processing once #268
- Added javadoc documentation on gitee(https://apidoc.gitee.com/free/Mybatis_PageHelper)
- Solve the problem of default reflection without cache fixed #275
- Optimizing mysql ifnull function causes paging performance problems (by miaogr)(This change was eventually changed to the following
aggregateFunctions
) - Jsqlparser has been upgraded to version 1.2, which is incompatible with 1.0 and has been resolved. fixed 273
- Remove the g(s)etFirstPage and g(s)etLastPage methods that are ambiguous in PageInfo
- Throws an exception that failed to parse when sorting fixed #257
- Resolve the initialization problem when there is no properties property when configuring the spring use
<bean>
. fixed #26 - Fix the problem that Oracle paging will leak data (by muyun12)
aggregateFunctions
: The default is the aggregate function of all common databases,
allowing you to manually add aggregate functions ( affecting the number of rows ).
All functions that start with aggregate functions will be wrap as subquery.
Other functions and columns will be replaced with count(0).
After adding the aggregateFunctions
parameter, the biggest difference from the original is that if there is select ifnull(XXX,YY) from table ...
, the original count query is
select count(0) from (select ifnull(xxx,yy) from table ... ) temp_count
now distinguishes aggregate functions, if not aggregate functions, it will become
select count(0) from table ...
.
The aggregate function prefixes included by default are as the above code.
5.0.4 - 2017-08-01
中文
- 增加对
Phoenix
数据库的简单配置支持,配置helperDialect=phoenix
即可,也可以自动识别Phoenix
数据库的 jdbc url。 - count 查询的缓存
msCountMap
key 改为String
类型,key 为 count 查询的MappedStatement
的 id。 - 增加
countSuffix
count 查询后缀配置参数,该参数是针对PageInterceptor
配置的,默认值为_COUNT
。 - 增加手写 count 查询支持,详情看下面介绍。
增加手写 count 查询支持
增加 countSuffix
count 查询后缀配置参数,该参数是针对 PageInterceptor
配置的,默认值为 _COUNT
。
分页插件会优先通过当前查询的 msId + countSuffix
查找手写的分页查询。
如果存在就使用手写的 count 查询,如果不存在,仍然使用之前的方式自动创建 count 查询。
例如,如果存在下面两个查询:
<select id="selectLeftjoin" resultType="com.github.pagehelper.model.Country">
select a.id,b.countryname,a.countrycode from country a
left join country b on a.id = b.id
order by a.id
</select>
<select id="selectLeftjoin_COUNT" resultType="Long">
select count(distinct a.id) from country a
left join country b on a.id = b.id
</select>
上面的 countSuffix
使用的默认值 _COUNT
,分页插件会自动获取到 selectLeftjoin_COUNT
查询,这个查询需要自己保证结果数正确。
返回值的类型必须是resultType="Long"
,入参使用的和 selectLeftjoin
查询相同的参数,所以在 SQL 中要按照 selectLeftjoin
的入参来使用。
因为 selectLeftjoin_COUNT
方法是自动调用的,所以不需要在接口提供相应的方法,如果需要单独调用,也可以提供。
上面方法执行输出的部分日志如下:
DEBUG [main] - ==> Preparing: select count(distinct a.id) from country a left join country b on a.id = b.id
DEBUG [main] - ==> Parameters:
TRACE [main] - <== Columns: C1
TRACE [main] - <== Row: 183
DEBUG [main] - <== Total: 1
DEBUG [main] - Cache Hit Ratio [com.github.pagehelper.mapper.CountryMapper]: 0.0
DEBUG [main] - ==> Preparing: select a.id,b.countryname,a.countrycode from country a left join country b on a.id = b.id order by a.id LIMIT 10
DEBUG [main] - ==> Parameters:
TRACE [main] - <== Columns: ID, COUNTRYNAME, COUNTRYCODE
TRACE [main] - <== Row: 1, Angola, AO
TRACE [main] - <== Row: 2, Afghanistan, AF
TRACE [main] - <== Row: 3, Albania, AL
English
- Add a simple configuration support for the Phoenix database, You can configure
helperDialect=phoenix
. Can also automatically identify the Phoenix database jdbc url. - Simplified cache of
msCountMap
- Add
countSuffix
count query suffix configuration parameters, this parameter is configured forPageInterceptor
, the default value is_COUNT
. - Add custom count query support, see below for details.
Add custom count query support
Add countSuffix
count query suffix configuration parameters, this parameter is configured for PageInterceptor
, the default value is _COUNT
.
The paging plugin will preferentially find the handwritten paging query by the current query msId + countSuffix
.
If there is no custom query, the query is still automatically created using the previous way.
For example, if there are two queries:
<select id="selectLeftjoin" resultType="com.github.pagehelper.model.Country">
select a.id,b.countryname,a.countrycode from country a
left join country b on a.id = b.id
order by a.id
</select>
<select id="selectLeftjoin_COUNT" resultType="Long">
select count(distinct a.id) from country a
left join country b on a.id = b.id
</select>
The above countSuffix
uses the default value of _COUNT
, and the paging plugin will automatically get the query to selectLeftjoin_COUNT
. This query needs to ensure that the result is correct.
The value of the return value must be resultType =" Long "
, and the same parameter used by selectLeftjoin
'is used, so it is used in SQL to follow the selection of selectLeftjoin
'.
Because the selectLeftjoin_COUNT
method is invoked automatically, there is no need to provide the appropriate method on the interface, or if it is required to be invoked separately.
The above method to perform the portion of the output log is as follows:
DEBUG [main] - ==> Preparing: select count(distinct a.id) from country a left join country b on a.id = b.id
DEBUG [main] - ==> Parameters:
TRACE [main] - <== Columns: C1
TRACE [main] - <== Row: 183
DEBUG [main] - <== Total: 1
DEBUG [main] - Cache Hit Ratio [com.github.pagehelper.mapper.CountryMapper]: 0.0
DEBUG [main] - ==> Preparing: select a.id,b.countryname,a.countrycode from country a left join country b on a.id = b.id order by a.id LIMIT 10
DEBUG [main] - ==> Parameters:
TRACE [main] - <== Columns: ID, COUNTRYNAME, COUNTRYCODE
TRACE [main] - <== Row: 1, Angola, AO
TRACE [main] - <== Row: 2, Afghanistan, AF
TRACE [main] - <== Row: 3, Albania, AL
PageHelper v5.0.0
- Use QueryInterceptor spec to handle paging logic
- New pagination plugin interceptor
com.github.pagehelper.PageInterceptor
- New
Dialect
PageHelper
is a special implementation class, the previous function is implemented in more user-friendly ways - New pagination plugin only a
dialect
parameter, the defaultdialect
isPageHelper
PageHelper
continue to support previously provided parameters, Among the latest to use the document has been fully updatedPageHelper
has ahelperDialect
parameter which is the same functional as the previousdialect
- Added paging implementation based on pure
RowBounds
andPageRowBounds
,
incom.github. pagehelper. dialect. rowbounds
package, it is used asdialect
Parameter sample implementation, more detailed documentation will be added later - Removed inappropriate orderby functions that appear in pagination plugin. It will provide a separate sort plug-ins in the future
- Remove
PageHelper
are less commonly used methods - A new document, an important part of the update has been mentioned in the changelog, provides the English version of this document
- fix bug #149
- renamed Db2RowDialect to Db2RowBoundsDialect
- All thrown exceptions being replaced by PageException
中文:
- 使用 QueryInterceptor 规范 处理分页逻辑
- 新的分页插件拦截器为
com.github.pagehelper.PageInterceptor
- 新的
PageHelper
是一个特殊的Dialect
实现类,以更友好的方式实现了以前的功能 - 新的分页插件仅有
dialect
一个参数,默认的dialect
实现类为PageHelper
PageHelper
仍然支持以前提供的参数,在最新的使用文档中已经全部更新PageHelper
的helperDialect
参数和以前的dialect
功能一样,具体可以看文档的参数说明- 增加了基于纯
RowBounds
和PageRowBounds
的分页实现,在com.github.pagehelper.dialect.rowbounds
包中,这是用于作为dialect
参数示例的实现,后面会补充更详细的文档 - 去掉了不适合出现在分页插件中的 orderby 功能,以后会提供单独的排序插件
- 去掉了
PageHelper
中不常用的方法 - 新的文档,更新历来更新日志中提到的重要内容,提供英文版本文档
- 解决 bug #149
- 将 Db2RowDialect 改为 Db2RowBoundsDialect
- 所有分页插件抛出的异常改为 PageException
Support Spring Boot:
https://github.com/pagehelper/pagehelper-spring-boot