Module bus.pager

Class PaginationHandler

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Logs the pagination call stack in debug mode.
    Retrieves the current pagination dialect.
    boolean
    Checks if debug mode is enabled.
    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.
    protected void
    processSelect(net.sf.jsqlparser.statement.select.Select select, int index, String sql, Object obj)
    Processes a SELECT statement, logging pagination-related information.
    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.
    boolean
    Sets the properties for the pagination handler, initializing the cache and dialect.

    Methods inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler

    getMappedStatement, getMappedStatement, getMetaObject, getSqlParserInfo, mapperBoundSql, mapperStatementHandler, realTarget, setAdditionalParameter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.core.Handler

    after, before

    Methods 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:
      isQuery in interface org.miaixz.bus.mapper.handler.MapperHandler
      Parameters:
      executor - the MyBatis executor
      mappedStatement - the MappedStatement object
      parameter - the query parameters
      rowBounds - the pagination parameters
      resultHandler - the result handler
      boundSql - 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:
      query in interface org.miaixz.bus.mapper.handler.MapperHandler
      Parameters:
      result - the pagination result
      executor - the MyBatis executor
      mappedStatement - the MappedStatement object
      parameter - the query parameters
      rowBounds - the pagination parameters
      resultHandler - the result handler
      boundSql - 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:
      processSelect in class SqlParserHandler
      Parameters:
      select - the SELECT statement object
      index - the index of the statement
      sql - the original SQL statement
      obj - additional object
    • setProperties

      public boolean setProperties(Properties properties)
      Sets the properties for the pagination handler, initializing the cache and dialect.
      Specified by:
      setProperties in interface org.miaixz.bus.core.Handler
      Parameters:
      properties - the configuration properties
      Returns:
      true if properties were set successfully
    • getDialect

      public Dialect getDialect()
      Retrieves the current pagination dialect.
      Returns:
      the pagination dialect