Skip to content

5.3.0 - 2021-10-07

Compare
Choose a tag to compare
@abel533 abel533 released this 08 Oct 03:12
· 102 commits to master since this release
  • 增加 AutoDialect 接口用于自动获取数据库类型,可以通过 autoDialectClass 配置为自己的实现类,默认使用 DataSourceNegotiationAutoDialect,优先根据连接池获取。
    默认实现中,增加针对 hikari,druid,tomcat-jdbc,c3p0,dbcp 类型数据库连接池的特殊处理,直接从配置获取jdbcUrl,当使用其他类型数据源时,仍然使用旧的方式获取连接在读取jdbcUrl。
    想要使用和旧版本完全相同方式时,可以配置 autoDialectClass=old。当数据库连接池类型非常明确时,建议配置为具体值,例如使用 hikari 时,配置 autoDialectClass=hikari
    ,使用其他连接池时,配置为自己的实现类。
  • 支持运行时动态指定使用的 dialect 实现,例如 PageHelper.startPage(1, 10).using("oracle");
    或者 PageHelper.startPage(2, 10).using("org.exmaple.CustomDialect");
  • PageInfo 增加空实例常量属性 PageInfo.EMPTY 以及内容判断 boolean hasContent()
  • 启动中增加 banner, 需要日志级别 debug,可以通过 -Dpagehelper.banner=false 或者环境变量 PAGEHELPER_BANNER=false 关闭
     DEBUG [main] -
     
     ,------.                           ,--.  ,--.         ,--.                         
     |  .--. '  ,--,--.  ,---.   ,---.  |  '--'  |  ,---.  |  |  ,---.   ,---.  ,--.--.
     |  '--' | ' ,-.  | | .-. | | .-. : |  .--.  | | .-. : |  | | .-. | | .-. : |  .--'
     |  | --'  \ '-'  | ' '-' ' \   --. |  |  |  | \   --. |  | | '-' ' \   --. |  |    
     `--'       `--`--' .`-  /   `----' `--'  `--'  `----' `--' |  |-'   `----' `--'    
     `---'                                   `--'                        is intercepting.
    
    增加 banner 的目的在于,如果你配置了多次分页插件,你会看到 banner 输出多次,你可以在 PageInterceptor 构造方法断点看看那些地方进行了实例化。
  • 完善 Count 查询,当存在 having 时,不在优化查询列。查询列存在有别名的函数或者运算时也不优化查询列,避免 order by 或 having 中使用的别名不存在。
  • 增加判断处理某些数据(如 TDEngine)查询 count 无结果时返回 null
  • 添加 Firebird 数据库支持和 SqlServer2012 分页语法相同。
  • 添加 impala 数据库自动识别。
  • JSqlParser 升级为 4.2 版本。

距离上次更新3个月左右,这次更新直接让假期少了3天 🏃 ,关了 GitHub 和 Gitee 上的 200 多个issue,不一定所有问题都得到了处理,如果你还有疑问,可以继续提 issue,下个大版本会考虑直接 6.0,计划全部升级到 java 8,功能保持不变。


  • Add AutoDialect interface to automatically obtain the database type, which can be configured as its own
    implementation class through autoDialectClass. By default, DataSourceNegotiationAutoDialect is used, which is
    obtained according to the connection pool first. In the default implementation, special processing is added
    for hikari,druid,tomcat-jdbc,c3p0,dbcp type database connection pools, and jdbcUrl are obtained directly from the
    configuration. When other types of data sources are used, the connection is still obtained in the old way. You can
    configure autoDialectClass=old when you want to use exactly the same way as the old version. When the database
    connection pool type is very clear, it is recommended to configure it as a specific value. For example, when using
    hikari, configure autoDialectClass=hikari, and when using other connection pools, configure it as its own
    implementation class.
  • Enable dynamic designation of dialect implementation at runtime, such
    as PageHelper.startPage(1, 10).using("oracle"); Or PageHelper.startPage(2, 10).using("org.exmaple.CustomDialect");
  • PageInfo adds the empty instance constant attribute PageInfo.EMPTY and the content judgment boolean hasContent()
    .
  • Adding banner to startup requires log level debug, which can be closed by -Dpagehelper.banner=false or environment
    variable PAGEHELPER_BANNER=false.
     DEBUG [main] -
     
     ,------.                           ,--.  ,--.         ,--.                         
     |  .--. '  ,--,--.  ,---.   ,---.  |  '--'  |  ,---.  |  |  ,---.   ,---.  ,--.--.
     |  '--' | ' ,-.  | | .-. | | .-. : |  .--.  | | .-. : |  | | .-. | | .-. : |  .--'
     |  | --'  \ '-'  | ' '-' ' \   --. |  |  |  | \   --. |  | | '-' ' \   --. |  |    
     `--'       `--`--' .`-  /   `----' `--'  `--'  `----' `--' |  |-'   `----' `--'    
     `---'                                   `--'                        is intercepting.
    
    The purpose of adding banner is that if you configure paging plug-ins multiple times, you will see banner output
    multiple times, and you can see where it has been instantiated at the breakpoint of the PageInterceptor constructor.
  • Improve the Count query. When having exists, the query column is not optimized. The query column is not optimized when
    there are functions or operations with aliases in the column, so as to avoid that aliases used in order by or having
    do not exist.
  • It is judged that processing some data (such as TDEngine) returns null when there is no result in querying count.
  • Adding Firebird database support is the same as SqlServer2012 paging syntax.
  • Add impala database automatic recognition.
  • Upgrade JSqlParser to version 4.2.