Giter Club home page Giter Club logo

mybatis-pagehelper's Introduction

#Mybatis分页插件 - PageHelper

如果你也在用Mybatis,建议尝试该分页插件,这一定是最方便使用的分页插件。

分页插件支持任何复杂的单表、多表分页,部分特殊情况请看重要提示

想要使用分页插件?请看如何使用分页插件

##物理分页

该插件目前支持以下数据库的物理分页:

  1. Oracle
  2. Mysql
  3. MariaDB
  4. SQLite
  5. Hsqldb
  6. PostgreSQL
  7. DB2
  8. SqlServer(2005+)
  9. Informix

配置dialect属性时,使用小写形式:

oracle,mysql,mariadb,sqlite,hsqldb,postgresql,db2,sqlserver,informix

##分页插件支持MyBatis3.2.0~3.3.0(包含)

##分页插件最新版本为3.7.5

###Maven坐标

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>3.7.5</version>
</dependency>

###下载JAR包

分页插件pagehelper.jar:

由于使用了sql解析工具,你还需要下载jsqlparser.jar(这个文件完全独立,不依赖其他):

##4.0.0-SNAPSHOT 开发版:

  • 配置属性dialect不在强制要求,可以不写,分页插件会自动判断

  • 增加对排序的支持

  • 可以单独使用PageHelper.orderBy(String orderBy)对查询语句增加排序

  • PageHelper.orderBy(String orderBy)也可以配合startPage的其他方法使用

  • 可以使用PageHelper.startPage(int start,int size,String orderBy)对分页查询进行排序

  • 修改分页查询的处理逻辑,主要是将原sqlSource包装成可以分页和排序的sqlSource

##3.7.5更新日志:

  • 增加对MyBatis3.2.0以上版本的校验,如果是不是3.2.0以上版本,会抛出异常提示

  • 解决3.7.1更新中实际没有解决的入参为不可变Map类型时的错误

##3.7.4更新日志:

  • 为了支持3.3.0去掉了分页插件自带的SytemObjectMetaObject类(该类在早期版本为了支持3.2.0以前的MyBatis)

  • 最新支持MyBatis3.2.0到3.3.0版本

##3.7.3更新日志:

  • Page继承的ArrayList,会根据pageSize初始化大小,这就导致当pageSize过大(如Integer.MAX_VALUE)的内存溢出(实际数据量很小),此处改为初始化大小为0的List

  • 当想查询某页后面的全部数据时,可以使用PageHelper.startPage(pageNum, Integer.MAX_VALUE)进行分页,RowBounds(offset, Integer.MAX_VALUE)一样。

  • 针对PageHelper.startPage(1, Integer.MAX_VALUE)优化,会取消分页,直接查询全部数据(能起到pageSizeZero参数所起的作用)。

  • 针对RowBounds(0, Integer.MAX_VALUE)优化,会取消分页,直接查询全部数据(能起到pageSizeZero参数所起的作用)。

##3.7.2更新日志:

  • jsqlparser解析sql会抛出Error异常,由于只捕获Exception,所以导致部分解析失败的sql无法使用嵌套方式处理,所以修改为捕获Throwable

##3.7.1更新日志:

  • 增加Informix数据库支持,设置dialect值为informix即可
  • 解决入参为不可变Map类型时的错误

##3.7.0更新日志:

  • 由于orderby参数经常被错误认为的使用,因此该版本全面移除了orderby
  • Page<E>移除orderby属性
  • PageHelperstartPage方法中,移除包含orderby参数的方法,sqlserver相关包含该参数的全部移除
  • 对SqlServer进行分页查询时,请在sql中包含order by语句,否则会抛出异常
  • offsetAsPageNum=false的时候,由于PageNum问题,RowBounds查询的时候reasonable会强制为false,已解决
  • 少数情况下的select中包含单个函数查询时,会使用嵌套的count查询

##项目文档wiki

###如何使用分页插件

如果要使用分页插件,这篇文档一定要看,看完肯定没有问题。

如果和Spring集成不熟悉,可以参考下面两个MyBatis和Spring集成的框架

只有基础的配置信息,没有任何现成的功能,作为新手入门搭建框架的基础

这两个集成框架集成了MyBatis分页插件和MyBatis通用Mapper。

###更新日志

包含全部的详细的更新日志。

###重要提示

提示很重要,建议一定看一遍!

###提交(gitosc)BUG

##相关链接

对应于oschub的项目地址:http://git.oschina.net/free/Mybatis_PageHelper

对应于github的项目地址:https://github.com/pagehelper/Mybatis-PageHelper

Mybatis-Sample(分页插件测试项目):http://git.oschina.net/free/Mybatis-Sample

Mybatis项目:https://github.com/mybatis/mybatis-3

Mybatis文档:http://mybatis.github.io/mybatis-3/zh/index.html

Mybatis专栏:

作者博客:

作者QQ: 120807756

作者邮箱: [email protected]

Mybatis工具群: 211286137 (Mybatis相关工具插件等等)

mybatis-pagehelper's People

Contributors

abel533 avatar pagehelper avatar leaves615 avatar

Stargazers

葛俊 avatar

Forkers

wangjun0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.