java.lang.Object
org.miaixz.bus.pager.dialect.AbstractDialect
org.miaixz.bus.pager.dialect.AbstractPaging
org.miaixz.bus.pager.dialect.base.SqlServer
- All Implemented Interfaces:
Dialect
- Direct Known Subclasses:
SqlServer2012
Database dialect for SQL Server. This class provides SQL Server-specific implementations for pagination SQL
generation and parameter processing. It also handles SQL caching and replacement for specific SQL Server syntax like
`with(nolock)`.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionCache for count SQL queries.Cache for paginated SQL queries.protected ReplaceSqlUtility for replacing and restoring SQL parts, especially for `with(nolock)`.protected SqlServerSqlParserSQL Server specific SQL parser for pagination.Fields inherited from class org.miaixz.bus.pager.dialect.AbstractPaging
PAGEPARAMETER_FIRST, PAGEPARAMETER_SECOND, SUFFIX_COUNT, SUFFIX_PAGEFields inherited from class org.miaixz.bus.pager.dialect.AbstractDialect
countSqlParser, orderBySqlParser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCountSql(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 countKey) Generates the SQL for the count query for SQL Server.getPageSql(String sql, Page page, org.apache.ibatis.cache.CacheKey pageKey) Generates the SQL Server-specific pagination SQL.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) Overrides the parent method to handle SQL Server specific pagination, especially for `with(nolock)` clauses.processPageParameter(org.apache.ibatis.mapping.MappedStatement ms, Map<String, Object> paramMap, Page page, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey) Processes the pagination parameters for SQL Server.voidsetProperties(Properties properties) Sets the properties for this SQL Server dialect.Methods inherited from class org.miaixz.bus.pager.dialect.AbstractPaging
afterAll, afterCount, afterPage, beforeCount, beforePage, getLocalPage, handleParameter, processParameterObject, skipMethods 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
-
Field Details
-
sqlServerSqlParser
SQL Server specific SQL parser for pagination. -
CACHE_COUNTSQL
Cache for count SQL queries. -
CACHE_PAGESQL
Cache for paginated SQL queries. -
replaceSql
Utility for replacing and restoring SQL parts, especially for `with(nolock)`.
-
-
Constructor Details
-
SqlServer
public SqlServer()
-
-
Method Details
-
getCountSql
public String getCountSql(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 countKey) Generates the SQL for the count query for SQL Server. It uses a cache to store and retrieve count SQL, and applies SQL replacement rules.- Specified by:
getCountSqlin interfaceDialect- Overrides:
getCountSqlin classAbstractPaging- 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 parameterscountKey- the CacheKey for the count query- Returns:
- the generated count SQL string
-
processPageParameter
public Object processPageParameter(org.apache.ibatis.mapping.MappedStatement ms, Map<String, Object> paramMap, Page page, org.apache.ibatis.mapping.BoundSql boundSql, org.apache.ibatis.cache.CacheKey pageKey) Processes the pagination parameters for SQL Server. This implementation simply returns the parameter map as is.- Specified by:
processPageParameterin classAbstractPaging- Parameters:
ms- the MappedStatement objectparamMap- a map containing the query parameterspage- thePageobject containing pagination detailsboundSql- the BoundSql object for the querypageKey- the CacheKey for the paginated query- Returns:
- the processed parameter map
-
getPageSql
Generates the SQL Server-specific pagination SQL. It uses a cache to store and retrieve paginated SQL, applies SQL replacement rules, and substitutes pagination parameters.- Specified by:
getPageSqlin classAbstractPaging- Parameters:
sql- the original SQL stringpage- thePageobject containing pagination detailspageKey- the CacheKey for the paginated query- Returns:
- the SQL Server-specific paginated SQL string
-
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) Overrides the parent method to handle SQL Server specific pagination, especially for `with(nolock)` clauses. It first replaces specific SQL parts, then applies order by, and finally restores the SQL.- Specified by:
getPageSqlin interfaceDialect- Overrides:
getPageSqlin classAbstractPaging- 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
-
setProperties
Sets the properties for this SQL Server dialect. It initializes theSqlServerSqlParser,ReplaceSqlimplementation, and SQL caches.- Specified by:
setPropertiesin interfaceDialect- Overrides:
setPropertiesin classAbstractPaging- Parameters:
properties- the properties to set
-