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
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAll()Called after all pagination tasks are completed.booleanafterCount(long count, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds) Called after the count query has been executed to process the count result.Called after the pagination query has been executed to process the results.booleanbeforeCount(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.booleanbeforePage(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds) Determines whether the main pagination query should be executed.abstract StringgetPageSql(String sql, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.cache.CacheKey pageKey) Abstract method to generate the database-specific pagination SQL usingRowBounds.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.voidsetProperties(Properties properties) Sets the properties for this dialect.booleanskip(org.apache.ibatis.mapping.MappedStatement ms, Object parameterObject, org.apache.ibatis.session.RowBounds rowBounds) Determines whether to skip the pagination logic based on theRowBoundsobject.Methods inherited from class org.miaixz.bus.pager.dialect.AbstractDialect
getCountSqlMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 theRowBoundsobject. Pagination is skipped if the providedrowBoundsis the defaultRowBounds.DEFAULT.- Parameters:
ms- the MappedStatement objectparameterObject- the parameter object for the queryrowBounds- 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 therowBoundsis an instance ofRowBoundsand itscountproperty is null or true.- Parameters:
ms- the MappedStatement objectparameterObject- the parameter object for the queryrowBounds- 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 theRowBoundsobject and determines if the main pagination query should proceed.- Parameters:
count- the total number of records found by the count queryparameterObject- the parameter object for the queryrowBounds- 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. ForAbstractRowBounds, the parameter object is returned as is.- Parameters:
ms- the MappedStatement objectparameterObject- the original parameter object for the queryboundSql- the BoundSql object containing the original SQL and parameterspageKey- 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. ForAbstractRowBounds, it always returns true.- Parameters:
ms- the MappedStatement objectparameterObject- the parameter object for the queryrowBounds- 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 fromboundSqland delegates to an abstract method for database-specific pagination SQL generation.- Parameters:
ms- the MappedStatement objectboundSql- the BoundSql object containing the original SQL and parametersparameterObject- the parameter object for the queryrowBounds- the RowBounds object containing pagination parameterspageKey- 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 usingRowBounds. To be implemented by concrete dialect classes.- Parameters:
sql- the original SQL stringrowBounds- theRowBoundsobject containing offset and limitpageKey- 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. ForAbstractRowBounds, it simply returns the list of results as is.- Parameters:
pageList- the list of results from the paginated queryparameterObject- the parameter object for the queryrowBounds- 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
Sets the properties for this dialect. Delegates to the superclass to set common properties.- Specified by:
setPropertiesin interfaceDialect- Overrides:
setPropertiesin classAbstractDialect- Parameters:
properties- the properties to set
-