public class PaginationInnerInterceptor extends java.lang.Object implements InnerInterceptor
默认对 left join 进行优化,虽然能优化count,但是加上分页的话如果1对多本身结果条数就是不正确的
| 限定符和类型 | 字段和说明 |
|---|---|
protected static java.util.List<net.sf.jsqlparser.statement.select.SelectItem> |
COUNT_SELECT_ITEM |
protected static java.util.Map<java.lang.String,org.apache.ibatis.mapping.MappedStatement> |
countMsCache |
protected org.apache.ibatis.logging.Log |
logger |
protected java.lang.Long |
maxLimit
单页分页条数限制
|
protected boolean |
overflow
溢出总页数后是否进行处理
|
| 构造器和说明 |
|---|
PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType) |
PaginationInnerInterceptor(IDialect dialect) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected java.util.List<net.sf.jsqlparser.statement.select.OrderByElement> |
addOrderByElements(java.util.List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList,
java.util.List<net.sf.jsqlparser.statement.select.OrderByElement> orderByElements) |
protected java.lang.String |
autoCountSql(boolean optimizeCountSql,
java.lang.String sql)
获取自动优化的 countSql
|
void |
beforeQuery(org.apache.ibatis.executor.Executor executor,
org.apache.ibatis.mapping.MappedStatement ms,
java.lang.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) 操作前置处理
改改sql啥的 |
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,
java.lang.String countId)
获取指定的 id 的 MappedStatement
|
protected java.lang.String |
concatOrderBy(java.lang.String originalSql,
java.util.List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList)
查询SQL拼接Order By
|
protected boolean |
continuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
count 查询之后,是否继续执行分页
|
protected IDialect |
findIDialect(org.apache.ibatis.executor.Executor executor)
获取分页方言类的逻辑
|
protected void |
handlerLimit(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
处理超出分页条数限制,默认归为限制数
|
protected void |
handlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
处理页数溢出,默认设置为第一页
|
protected java.lang.String |
lowLevelCountSql(java.lang.String originalSql)
无法进行count优化时,降级使用此方法
|
void |
setProperties(java.util.Properties properties) |
boolean |
willDoQuery(org.apache.ibatis.executor.Executor executor,
org.apache.ibatis.mapping.MappedStatement ms,
java.lang.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了)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbeforePrepare, beforeUpdate, willDoUpdateprotected static final java.util.List<net.sf.jsqlparser.statement.select.SelectItem> COUNT_SELECT_ITEM
protected static final java.util.Map<java.lang.String,org.apache.ibatis.mapping.MappedStatement> countMsCache
protected final org.apache.ibatis.logging.Log logger
protected boolean overflow
protected java.lang.Long maxLimit
public PaginationInnerInterceptor(com.baomidou.mybatisplus.annotation.DbType dbType)
public PaginationInnerInterceptor(IDialect dialect)
public boolean willDoQuery(org.apache.ibatis.executor.Executor executor,
org.apache.ibatis.mapping.MappedStatement ms,
java.lang.Object parameter,
org.apache.ibatis.session.RowBounds rowBounds,
org.apache.ibatis.session.ResultHandler resultHandler,
org.apache.ibatis.mapping.BoundSql boundSql)
throws java.sql.SQLException
willDoQuery 在接口中 InnerInterceptorexecutor - Executor(可能是代理对象)ms - MappedStatementparameter - parameterrowBounds - rowBoundsresultHandler - resultHandlerboundSql - boundSqljava.sql.SQLExceptionpublic void beforeQuery(org.apache.ibatis.executor.Executor executor,
org.apache.ibatis.mapping.MappedStatement ms,
java.lang.Object parameter,
org.apache.ibatis.session.RowBounds rowBounds,
org.apache.ibatis.session.ResultHandler resultHandler,
org.apache.ibatis.mapping.BoundSql boundSql)
throws java.sql.SQLException
InnerInterceptorExecutor.query(MappedStatement, Object, RowBounds, ResultHandler, CacheKey, BoundSql) 操作前置处理
改改sql啥的
beforeQuery 在接口中 InnerInterceptorexecutor - Executor(可能是代理对象)ms - MappedStatementparameter - parameterrowBounds - rowBoundsresultHandler - resultHandlerboundSql - boundSqljava.sql.SQLExceptionprotected IDialect findIDialect(org.apache.ibatis.executor.Executor executor)
executor - Executorprotected org.apache.ibatis.mapping.MappedStatement buildCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms,
java.lang.String countId)
ms - MappedStatementcountId - idprotected org.apache.ibatis.mapping.MappedStatement buildAutoCountMappedStatement(org.apache.ibatis.mapping.MappedStatement ms)
ms - MappedStatementprotected java.lang.String autoCountSql(boolean optimizeCountSql,
java.lang.String sql)
optimizeCountSql - 是否进行优化sql - sqlprotected java.lang.String lowLevelCountSql(java.lang.String originalSql)
originalSql - 原始sqlprotected java.lang.String concatOrderBy(java.lang.String originalSql,
java.util.List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList)
originalSql - 需要拼接的SQLprotected java.util.List<net.sf.jsqlparser.statement.select.OrderByElement> addOrderByElements(java.util.List<com.baomidou.mybatisplus.core.metadata.OrderItem> orderList,
java.util.List<net.sf.jsqlparser.statement.select.OrderByElement> orderByElements)
protected boolean continuePage(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
page - 分页对象protected void handlerLimit(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
page - IPageprotected void handlerOverflow(com.baomidou.mybatisplus.core.metadata.IPage<?> page)
page - IPagepublic void setProperties(java.util.Properties properties)
setProperties 在接口中 InnerInterceptor