类 PaginationInnerInterceptor
java.lang.Object
com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor
- 所有已实现的接口:
InnerInterceptor
分页拦截器
默认对 left join 进行优化,虽然能优化count,但是加上分页的话如果1对多本身结果条数就是不正确的
- 从以下版本开始:
- 3.4.0
- 作者:
- hubin
-
字段概要
字段 -
构造器概要
构造器构造器说明PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType) PaginationInnerInterceptor(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) protected StringautoCountSql(com.baomidou.mybatisplus.core.metadata.IPage<?> page, String sql) 获取自动优化的 countSqlvoidbeforeQuery(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) Executor.query(MappedStatement, Object, RowBounds, ResultHandler, CacheKey, BoundSql)操作前置处理protected org.apache.ibatis.mapping.MappedStatementbuildAutoCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms) 构建 mp 自用自动的 MappedStatementprotected org.apache.ibatis.mapping.MappedStatementbuildCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms, String countId) 获取指定的 id 的 MappedStatementprotected booleanconcatOrderBy(String originalSql, List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList) 查询SQL拼接Order Byprotected booleancontinuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page) count 查询之后,是否继续执行分页booleanprotected IDialectfindIDialect(org.apache.ibatis.executor.Executor executor) 获取分页方言类的逻辑com.baomidou.mybatisplus.annotation.DbType数据库类型方言实现类org.apache.ibatis.logging.Log单页分页条数限制protected voidhandlerLimit(com.baomidou.mybatisplus.core.metadata.IPage<?> page, Long limit) 处理超出分页条数限制,默认归为限制数protected voidhandlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page) 处理页数溢出,默认设置为第一页inthashCode()boolean生成 countSql 优化掉 join 现在只支持 left joinboolean溢出总页数后是否进行处理protected StringlowLevelCountSql(String originalSql) 无法进行count优化时,降级使用此方法voidsetDbType(com.baomidou.mybatisplus.annotation.DbType dbType) 数据库类型voidsetDialect(IDialect dialect) 方言实现类voidsetMaxLimit(Long maxLimit) 单页分页条数限制voidsetOptimizeJoin(boolean optimizeJoin) 生成 countSql 优化掉 join 现在只支持 left joinvoidsetOverflow(boolean overflow) 溢出总页数后是否进行处理voidsetProperties(Properties properties) toString()booleanwillDoQuery(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了)从接口继承的方法 com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
beforeGetBoundSql, beforePrepare, beforeUpdate, willDoUpdate
-
字段详细资料
-
COUNT_SELECT_ITEM
获取jsqlparser中count的SelectItem -
countMsCache
-
logger
protected final org.apache.ibatis.logging.Log logger -
overflow
protected boolean overflow溢出总页数后是否进行处理 -
maxLimit
单页分页条数限制 -
optimizeJoin
protected boolean optimizeJoin生成 countSql 优化掉 join 现在只支持 left join- 从以下版本开始:
- 3.4.2
-
-
构造器详细资料
-
PaginationInnerInterceptor
public PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType) -
PaginationInnerInterceptor
-
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在接口中InnerInterceptor- 参数:
executor- Executor(可能是代理对象)ms- MappedStatementparameter- parameterrowBounds- rowBoundsresultHandler- resultHandlerboundSql- boundSql- 返回:
- 新的 boundSql
- 抛出:
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) throws SQLException 从接口复制的说明:InnerInterceptorExecutor.query(MappedStatement, Object, RowBounds, ResultHandler, CacheKey, BoundSql)操作前置处理改改sql啥的
- 指定者:
beforeQuery在接口中InnerInterceptor- 参数:
executor- Executor(可能是代理对象)ms- MappedStatementparameter- parameterrowBounds- rowBoundsresultHandler- resultHandlerboundSql- boundSql- 抛出:
SQLException
-
findIDialect
获取分页方言类的逻辑- 参数:
executor- Executor- 返回:
- 分页方言类
-
buildCountMappedStatement
protected org.apache.ibatis.mapping.MappedStatement buildCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms, String countId) 获取指定的 id 的 MappedStatement- 参数:
ms- MappedStatementcountId- id- 返回:
- MappedStatement
-
buildAutoCountMappedStatement
protected org.apache.ibatis.mapping.MappedStatement buildAutoCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms) 构建 mp 自用自动的 MappedStatement- 参数:
ms- MappedStatement- 返回:
- MappedStatement
-
autoCountSql
获取自动优化的 countSql- 参数:
page- 参数sql- sql- 返回:
- countSql
-
lowLevelCountSql
无法进行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
-
continuePage
protected boolean continuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page) count 查询之后,是否继续执行分页- 参数:
page- 分页对象- 返回:
- 是否
-
handlerLimit
处理超出分页条数限制,默认归为限制数- 参数:
page- IPage
-
handlerOverflow
protected void handlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page) 处理页数溢出,默认设置为第一页- 参数:
page- IPage
-
setProperties
- 指定者:
setProperties在接口中InnerInterceptor
-
getLogger
public org.apache.ibatis.logging.Log getLogger() -
isOverflow
public boolean isOverflow()溢出总页数后是否进行处理 -
getMaxLimit
单页分页条数限制 -
getDbType
public com.baomidou.mybatisplus.annotation.DbType getDbType()数据库类型查看
findIDialect(Executor)逻辑 -
getDialect
方言实现类查看
findIDialect(Executor)逻辑 -
isOptimizeJoin
public boolean isOptimizeJoin()生成 countSql 优化掉 join 现在只支持 left join- 从以下版本开始:
- 3.4.2
-
setOverflow
public void setOverflow(boolean overflow) 溢出总页数后是否进行处理 -
setMaxLimit
单页分页条数限制 -
setDbType
public void setDbType(com.baomidou.mybatisplus.annotation.DbType dbType) 数据库类型查看
findIDialect(Executor)逻辑 -
setDialect
方言实现类查看
findIDialect(Executor)逻辑 -
setOptimizeJoin
public void setOptimizeJoin(boolean optimizeJoin) 生成 countSql 优化掉 join 现在只支持 left join- 从以下版本开始:
- 3.4.2
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-