Module bus.pager

Class AbstractRowBounds

java.lang.Object
org.miaixz.bus.pager.dialect.AbstractDialect
org.miaixz.bus.pager.dialect.AbstractRowBounds
All Implemented Interfaces:
Dialect
Direct Known Subclasses:
Db2RowBounds, HerdDBRowBounds, HsqldbRowBounds, InformixRowBounds, MySqlRowBounds, OracleRowBounds, PostgreSqlRowBounds, SqlServerRowBounds, XugudbRowBounds

public abstract class AbstractRowBounds extends AbstractDialect
Abstract base class for pagination based on MyBatis RowBounds. This class provides a foundation for dialects that implement pagination using offset and limit.
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields inherited from class org.miaixz.bus.pager.dialect.AbstractDialect

    countSqlParser, orderBySqlParser
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called after all pagination tasks are completed.
    boolean
    afterCount(long count, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    Called after the count query has been executed to process the count result.
    afterPage(List pageList, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    Called after the pagination query has been executed to process the results.
    boolean
    beforeCount(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    Determines whether a count query should be executed before the main pagination query.
    boolean
    beforePage(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    Determines whether the main pagination query should be executed.
    abstract String
    getPageSql(String sql, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
    Abstract method to generate the database-specific pagination SQL using RowBounds.
    getPageSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
    Generates the SQL for the paginated query.
    processParameterObject(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
    Processes the parameter object for pagination.
    void
    Sets the properties for this dialect.
    boolean
    skip(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
    Determines whether to skip the pagination logic based on the RowBounds object.

    Methods inherited from class org.miaixz.bus.pager.dialect.AbstractDialect

    getCountSql

    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.pager.Dialect

    asyncCountTask, isAsyncCount
  • Constructor Details

    • AbstractRowBounds

      public AbstractRowBounds()
  • Method Details

    • skip

      public boolean skip(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Determines whether to skip the pagination logic based on the RowBounds object. Pagination is skipped if the provided rowBounds is the default RowBounds.DEFAULT.
      Parameters:
      ms - the MappedStatement object
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      Returns:
      true if pagination should be skipped, false otherwise
    • beforeCount

      public boolean beforeCount(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Determines whether a count query should be executed before the main pagination query. A count query is executed if the rowBounds is an instance of RowBounds and its count property is null or true.
      Parameters:
      ms - the MappedStatement object
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      Returns:
      true if a count query should be executed, false otherwise
    • afterCount

      public boolean afterCount(long count, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Called after the count query has been executed to process the count result. It sets the total count in the RowBounds object and determines if the main pagination query should proceed.
      Parameters:
      count - the total number of records found by the count query
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      Returns:
      true to continue with the pagination query if count is greater than 0, false otherwise
    • processParameterObject

      public Object processParameterObject(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey)
      Processes the parameter object for pagination. For AbstractRowBounds, the parameter object is returned as is.
      Parameters:
      ms - the MappedStatement object
      parameterObject - the original parameter object for the query
      boundSql - the BoundSql object containing the original SQL and parameters
      pageKey - the CacheKey for the paginated query
      Returns:
      the original parameter object
    • beforePage

      public boolean beforePage(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Determines whether the main pagination query should be executed. For AbstractRowBounds, it always returns true.
      Parameters:
      ms - the MappedStatement object
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      Returns:
      always true, indicating the pagination query should be executed
    • getPageSql

      public String getPageSql(org.apache.ibatis.mapping.MappedStatement ms, org.apache.ibatis.mapping.BoundSql boundSql, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
      Generates the SQL for the paginated query. It retrieves the original SQL from boundSql and delegates to an abstract method for database-specific pagination SQL generation.
      Parameters:
      ms - the MappedStatement object
      boundSql - the BoundSql object containing the original SQL and parameters
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      pageKey - the CacheKey for the paginated query
      Returns:
      the generated paginated SQL string
    • getPageSql

      public abstract String getPageSql(String sql, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey)
      Abstract method to generate the database-specific pagination SQL using RowBounds. To be implemented by concrete dialect classes.
      Parameters:
      sql - the original SQL string
      rowBounds - the RowBounds object containing offset and limit
      pageKey - the CacheKey for the paginated query
      Returns:
      the database-specific paginated SQL string
    • afterPage

      public Object afterPage(List pageList, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds)
      Called after the pagination query has been executed to process the results. For AbstractRowBounds, it simply returns the list of results as is.
      Parameters:
      pageList - the list of results from the paginated query
      parameterObject - the parameter object for the query
      rowBounds - the RowBounds object containing pagination parameters
      Returns:
      the list of paginated results
    • afterAll

      public void afterAll()
      Called after all pagination tasks are completed. This implementation does nothing.
    • setProperties

      public void setProperties(Properties properties)
      Sets the properties for this dialect. Delegates to the superclass to set common properties.
      Specified by:
      setProperties in interface Dialect
      Overrides:
      setProperties in class AbstractDialect
      Parameters:
      properties - the properties to set