java.lang.Object
org.miaixz.bus.mapper.handler.AbstractSqlHandler
org.miaixz.bus.pager.handler.SqlParserHandler
org.miaixz.bus.pager.handler.PaginationHandler
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Handler,org.miaixz.bus.mapper.handler.MapperHandler
public class PaginationHandler
extends SqlParserHandler
implements org.miaixz.bus.mapper.handler.MapperHandler
Pagination handler for query pagination. This class intercepts query operations to apply pagination logic, including
count queries and dialect-specific SQL modifications.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler
DEFAULT_REFLECTOR_FACTORY, DELEGATE_BOUNDSQL, DELEGATE_BOUNDSQL_SQL, DELEGATE_MAPPEDSTATEMENT, MAPPEDSTATEMENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidLogs the pagination call stack in debug mode.Retrieves the current pagination dialect.booleanisDebug()Checks if debug mode is enabled.booleanisQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Determines whether a pagination query needs to be executed.protected voidprocessSelect(net.sf.jsqlparser.statement.select.Select select, int index, String sql, Object obj) Processes a SELECT statement, logging pagination-related information.voidquery(Object result, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Executes the pagination query, handling both COUNT and pagination logic.booleansetProperties(Properties properties) Sets the properties for the pagination handler, initializing the cache and dialect.Methods inherited from class org.miaixz.bus.pager.handler.SqlParserHandler
parse, parserMulti, parserSingle, parseStatements, processDelete, processInsert, processParser, processUpdate, validateSqlMethods inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler
getMappedStatement, getMappedStatement, getMetaObject, getSqlParserInfo, mapperBoundSql, mapperStatementHandler, realTarget, setAdditionalParameterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.Handler
after, beforeMethods inherited from interface org.miaixz.bus.mapper.handler.MapperHandler
getBoundSql, isUpdate, prepare, update
-
Constructor Details
-
PaginationHandler
public PaginationHandler()
-
-
Method Details
-
isDebug
public boolean isDebug()Checks if debug mode is enabled.- Returns:
- true if debug mode is enabled, false otherwise
-
debugStackTraceLog
protected void debugStackTraceLog()Logs the pagination call stack in debug mode. -
isQuery
public boolean isQuery(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Determines whether a pagination query needs to be executed.- Specified by:
isQueryin interfaceorg.miaixz.bus.mapper.handler.MapperHandler- Parameters:
executor- the MyBatis executormappedStatement- the MappedStatement objectparameter- the query parametersrowBounds- the pagination parametersresultHandler- the result handlerboundSql- the bound SQL- Returns:
- true if pagination is required, false otherwise
-
query
public void query(Object result, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Executes the pagination query, handling both COUNT and pagination logic.- Specified by:
queryin interfaceorg.miaixz.bus.mapper.handler.MapperHandler- Parameters:
result- the pagination resultexecutor- the MyBatis executormappedStatement- the MappedStatement objectparameter- the query parametersrowBounds- the pagination parametersresultHandler- the result handlerboundSql- the bound SQL
-
processSelect
protected void processSelect(net.sf.jsqlparser.statement.select.Select select, int index, String sql, Object obj) Processes a SELECT statement, logging pagination-related information.- Overrides:
processSelectin classSqlParserHandler- Parameters:
select- the SELECT statement objectindex- the index of the statementsql- the original SQL statementobj- additional object
-
setProperties
Sets the properties for the pagination handler, initializing the cache and dialect.- Specified by:
setPropertiesin interfaceorg.miaixz.bus.core.Handler- Parameters:
properties- the configuration properties- Returns:
- true if properties were set successfully
-
getDialect
Retrieves the current pagination dialect.- Returns:
- the pagination dialect
-