类 PaginationInnerInterceptor

java.lang.Object
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
所有已实现的接口:
com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor

public class PaginationInnerInterceptor extends Object implements com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
分页拦截器

默认对 left join 进行优化,虽然能优化count,但是加上分页的话如果1对多本身结果条数就是不正确的

从以下版本开始:
3.4.0
作者:
hubin
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    protected static final List<net.sf.jsqlparser.statement.select.SelectItem<?>>
    获取jsqlparser中count的SelectItem
    protected static final Map<String,org.apache.ibatis.mapping.MappedStatement>
     
    protected final org.apache.ibatis.logging.Log
     
    protected Long
    单页分页条数限制
    protected boolean
    生成 countSql 优化掉 join 现在只支持 left join
    protected boolean
    溢出总页数后是否进行处理
  • 构造器概要

    构造器
    构造器
    说明
     
    PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType)
     
    PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect dialect)
     
  • 方法概要

    修饰符和类型
    方法
    说明
    protected List<net.sf.jsqlparser.statement.select.OrderByElement>
    addOrderByElements(List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList, List<net.sf.jsqlparser.statement.select.OrderByElement> orderByElements)
     
    autoCountSql(com.baomidou.mybatisplus.core.metadata.IPage<?> page, String sql)
    获取自动优化的 countSql
    void
    beforeQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql)
     
    protected org.apache.ibatis.mapping.MappedStatement
    buildAutoCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms)
    构建 mp 自用自动的 MappedStatement
    protected org.apache.ibatis.mapping.MappedStatement
    buildCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms, String countId)
    获取指定的 id 的 MappedStatement
    protected boolean
     
    concatOrderBy(String originalSql, List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList)
    查询SQL拼接Order By
    protected boolean
    continuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
    count 查询之后,是否继续执行分页
    boolean
     
    protected com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect
    findIDialect(org.apache.ibatis.executor.Executor executor)
    获取分页方言类的逻辑
    com.baomidou.mybatisplus.annotation.DbType
    数据库类型
    com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect
    方言实现类
    org.apache.ibatis.logging.Log
     
    单页分页条数限制
    protected void
    handlerLimit(com.baomidou.mybatisplus.core.metadata.IPage<?> page, Long limit)
    处理超出分页条数限制,默认归为限制数
    protected void
    handlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
    处理页数溢出,默认设置为第一页
    int
     
    boolean
    生成 countSql 优化掉 join 现在只支持 left join
    boolean
    溢出总页数后是否进行处理
    protected String
    lowLevelCountSql(String originalSql)
    无法进行count优化时,降级使用此方法
    void
    setDbType(com.baomidou.mybatisplus.annotation.DbType dbType)
    数据库类型
    void
    setDialect(com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect dialect)
    方言实现类
    void
    setMaxLimit(Long maxLimit)
    单页分页条数限制
    void
    setOptimizeJoin(boolean optimizeJoin)
    生成 countSql 优化掉 join 现在只支持 left join
    void
    setOverflow(boolean overflow)
    溢出总页数后是否进行处理
    void
     
     
    boolean
    willDoQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql)
    这里进行count,如果count为0这返回false(就是不再执行sql了)

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    从接口继承的方法 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor

    beforeGetBoundSql, beforePrepare, beforeUpdate, willDoUpdate
  • 字段详细资料

    • COUNT_SELECT_ITEM

      protected static final List<net.sf.jsqlparser.statement.select.SelectItem<?>> COUNT_SELECT_ITEM
      获取jsqlparser中count的SelectItem
    • countMsCache

      protected static final Map<String,org.apache.ibatis.mapping.MappedStatement> countMsCache
    • logger

      protected final org.apache.ibatis.logging.Log logger
    • overflow

      protected boolean overflow
      溢出总页数后是否进行处理
    • maxLimit

      protected Long maxLimit
      单页分页条数限制
    • optimizeJoin

      protected boolean optimizeJoin
      生成 countSql 优化掉 join 现在只支持 left join
      从以下版本开始:
      3.4.2
  • 构造器详细资料

    • PaginationInnerInterceptor

      public PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType)
    • PaginationInnerInterceptor

      public PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect dialect)
    • PaginationInnerInterceptor

      public PaginationInnerInterceptor()
  • 方法详细资料

    • willDoQuery

      public boolean willDoQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) throws SQLException
      这里进行count,如果count为0这返回false(就是不再执行sql了)
      指定者:
      willDoQuery 在接口中 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
      抛出:
      SQLException
    • beforeQuery

      public void beforeQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement ms, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql)
      指定者:
      beforeQuery 在接口中 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
    • findIDialect

      protected com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect findIDialect(org.apache.ibatis.executor.Executor executor)
      获取分页方言类的逻辑
      参数:
      executor - Executor
      返回:
      分页方言类
    • buildCountMappedStatement

      protected org.apache.ibatis.mapping.MappedStatement buildCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms, String countId)
      获取指定的 id 的 MappedStatement
      参数:
      ms - MappedStatement
      countId - id
      返回:
      MappedStatement
    • buildAutoCountMappedStatement

      protected org.apache.ibatis.mapping.MappedStatement buildAutoCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms)
      构建 mp 自用自动的 MappedStatement
      参数:
      ms - MappedStatement
      返回:
      MappedStatement
    • autoCountSql

      public String autoCountSql(com.baomidou.mybatisplus.core.metadata.IPage<?> page, String sql)
      获取自动优化的 countSql
      参数:
      page - 参数
      sql - sql
      返回:
      countSql
    • lowLevelCountSql

      protected String lowLevelCountSql(String originalSql)
      无法进行count优化时,降级使用此方法
      参数:
      originalSql - 原始sql
      返回:
      countSql
    • concatOrderBy

      public String concatOrderBy(String originalSql, List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList)
      查询SQL拼接Order By
      参数:
      originalSql - 需要拼接的SQL
      返回:
      ignore
    • addOrderByElements

      protected List<net.sf.jsqlparser.statement.select.OrderByElement> addOrderByElements(List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList, List<net.sf.jsqlparser.statement.select.OrderByElement> orderByElements)
    • continuePage

      protected boolean continuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
      count 查询之后,是否继续执行分页
      参数:
      page - 分页对象
      返回:
      是否
    • handlerLimit

      protected void handlerLimit(com.baomidou.mybatisplus.core.metadata.IPage<?> page, Long limit)
      处理超出分页条数限制,默认归为限制数
      参数:
      page - IPage
    • handlerOverflow

      protected void handlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
      处理页数溢出,默认设置为第一页
      参数:
      page - IPage
    • setProperties

      public void setProperties(Properties properties)
      指定者:
      setProperties 在接口中 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
    • getLogger

      public org.apache.ibatis.logging.Log getLogger()
    • isOverflow

      public boolean isOverflow()
      溢出总页数后是否进行处理
    • getMaxLimit

      public Long getMaxLimit()
      单页分页条数限制
    • getDbType

      public com.baomidou.mybatisplus.annotation.DbType getDbType()
      数据库类型

      查看 findIDialect(Executor) 逻辑

    • getDialect

      public com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect getDialect()
      方言实现类

      查看 findIDialect(Executor) 逻辑

    • isOptimizeJoin

      public boolean isOptimizeJoin()
      生成 countSql 优化掉 join 现在只支持 left join
      从以下版本开始:
      3.4.2
    • setOverflow

      public void setOverflow(boolean overflow)
      溢出总页数后是否进行处理
    • setMaxLimit

      public void setMaxLimit(Long maxLimit)
      单页分页条数限制
    • setDbType

      public void setDbType(com.baomidou.mybatisplus.annotation.DbType dbType)
      数据库类型

      查看 findIDialect(Executor) 逻辑

    • setDialect

      public void setDialect(com.baomidou.mybatisplus.extension.plugins.pagination.dialects.IDialect dialect)
      方言实现类

      查看 findIDialect(Executor) 逻辑

    • setOptimizeJoin

      public void setOptimizeJoin(boolean optimizeJoin)
      生成 countSql 优化掉 join 现在只支持 left join
      从以下版本开始:
      3.4.2
    • equals

      public boolean equals(Object o)
      覆盖:
      equals 在类中 Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object