Module bus.pager

Class CountExecutor

java.lang.Object
org.miaixz.bus.pager.binding.CountExecutor

public abstract class CountExecutor extends Object
Utility class for executing count queries in MyBatis pagination. This class handles the creation and execution of count SQL, as well as parameter processing.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Long
    executeAutoCount(Dialect dialect, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement countMs, Object parameter, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler)
    Executes an automatically generated count query.
    static Long
    executeManualCount(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement countMs, Object parameter, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.session.ResultHandler resultHandler)
    Executes a manually configured count query.
    static Map<String,Object>
    getAdditionalParameter(org.apache.ibatis.mapping.BoundSql boundSql)
    Retrieves the `additionalParameters` map from a BoundSql object using reflection.
    static org.apache.ibatis.mapping.MappedStatement
    getExistedMappedStatement(org.apache.ibatis.session.Configuration configuration, String msId)
    Attempts to retrieve an already existing MappedStatement from the configuration.
    static String[]
    getProviderMethodArgumentNames(org.apache.ibatis.builder.annotation.ProviderSqlSource providerSqlSource)
    Retrieves the `providerMethodArgumentNames` array from a ProviderSqlSource object using reflection.
    static <E> List<E>
    pageQuery(Dialect dialect, 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, org.apache.ibatis.cache.CacheKey cacheKey)
    Executes a paginated query.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CountExecutor

      public CountExecutor()
  • Method Details

    • getAdditionalParameter

      public static Map<String,Object> getAdditionalParameter(org.apache.ibatis.mapping.BoundSql boundSql)
      Retrieves the `additionalParameters` map from a BoundSql object using reflection.
      Parameters:
      boundSql - the BoundSql object
      Returns:
      a map of additional parameters
      Throws:
      org.miaixz.bus.core.lang.exception.PageException - if an IllegalAccessException occurs during field access
    • getProviderMethodArgumentNames

      public static String[] getProviderMethodArgumentNames(org.apache.ibatis.builder.annotation.ProviderSqlSource providerSqlSource)
      Retrieves the `providerMethodArgumentNames` array from a ProviderSqlSource object using reflection. This method is used for compatibility with different MyBatis versions.
      Parameters:
      providerSqlSource - the ProviderSqlSource object
      Returns:
      an array of provider method argument names, or null if the field does not exist or cannot be accessed
      Throws:
      org.miaixz.bus.core.lang.exception.PageException - if an IllegalAccessException occurs during field access
    • getExistedMappedStatement

      public static org.apache.ibatis.mapping.MappedStatement getExistedMappedStatement(org.apache.ibatis.session.Configuration configuration, String msId)
      Attempts to retrieve an already existing MappedStatement from the configuration. This supports custom count and page MappedStatements.
      Parameters:
      configuration - the MyBatis configuration
      msId - the ID of the MappedStatement to retrieve
      Returns:
      the MappedStatement if found, otherwise null
    • executeManualCount

      public static Long executeManualCount(org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement countMs, Object parameter, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.session.ResultHandler resultHandler) throws SQLException
      Executes a manually configured count query. The parameters for this query must be the same as the paginated method.
      Parameters:
      executor - the MyBatis executor
      countMs - the MappedStatement for the count query
      parameter - the parameter object for the query
      boundSql - the BoundSql object for the original query
      resultHandler - the result handler for the query
      Returns:
      the total count of records
      Throws:
      SQLException - if a database access error occurs
    • executeAutoCount

      public static Long executeAutoCount(Dialect dialect, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement countMs, Object parameter, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler) throws SQLException
      Executes an automatically generated count query.
      Parameters:
      dialect - the database dialect to use
      executor - the MyBatis executor
      countMs - the MappedStatement for the count query
      parameter - the parameter object for the query
      boundSql - the BoundSql object for the original query
      rowBounds - the RowBounds object containing pagination parameters
      resultHandler - the result handler for the query
      Returns:
      the total count of records
      Throws:
      SQLException - if a database access error occurs
    • pageQuery

      public static <E> List<E> pageQuery(Dialect dialect, 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, org.apache.ibatis.cache.CacheKey cacheKey) throws SQLException
      Executes a paginated query.
      Type Parameters:
      E - the type of elements in the result list
      Parameters:
      dialect - the database dialect to use
      executor - the MyBatis executor
      ms - the MappedStatement for the query
      parameter - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      resultHandler - the result handler for the query
      boundSql - the BoundSql object for the original query
      cacheKey - the CacheKey for the query
      Returns:
      a list of paginated results
      Throws:
      SQLException - if a database access error occurs