Class SqlPagingQueryUtils
java.lang.Object
org.springframework.batch.item.database.support.SqlPagingQueryUtils
Utility class that generates the actual SQL statements used by query
providers.
- Since:
- 2.0
- Author:
- Thomas Risberg, Dave Syer, Michael Minella, Mahmoud Ben Hassine
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
buildSortClause
(Map<String, Order> sortKeys) Generates ORDER BY attributes based on the sort keys.static String
Generates ORDER BY attributes based on the sort keys.static void
buildSortConditions
(AbstractSqlPagingQueryProvider provider, StringBuilder sql) Appends the where conditions required to query for the subsequent pages.static String
generateGroupedTopSqlQuery
(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String topClause) Generate SQL query string using a TOP clausestatic String
generateLimitGroupedSqlQuery
(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String limitClause) Deprecated.static String
generateLimitGroupedSqlQuery
(AbstractSqlPagingQueryProvider provider, String limitClause) Generate SQL query string using a LIMIT clausestatic String
generateLimitJumpToQuery
(AbstractSqlPagingQueryProvider provider, String limitClause) Generate SQL query string using a LIMIT clausestatic String
generateLimitSqlQuery
(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String limitClause) Generate SQL query string using a LIMIT clausestatic String
generateRowNumSqlQuery
(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String rowNumClause) Generate SQL query string using a ROW_NUM conditionstatic String
generateRowNumSqlQuery
(AbstractSqlPagingQueryProvider provider, String selectClause, boolean remainingPageQuery, String rowNumClause) Generate SQL query string using a ROW_NUM conditionstatic String
generateRowNumSqlQueryWithNesting
(AbstractSqlPagingQueryProvider provider, String selectClause, boolean remainingPageQuery, String rowNumClause) static String
generateRowNumSqlQueryWithNesting
(AbstractSqlPagingQueryProvider provider, String innerSelectClause, String outerSelectClause, boolean remainingPageQuery, String rowNumClause) static String
generateTopJumpToQuery
(AbstractSqlPagingQueryProvider provider, String topClause) Generate SQL query string using a TOP clausestatic String
generateTopSqlQuery
(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String topClause) Generate SQL query string using a TOP clause
-
Constructor Details
-
SqlPagingQueryUtils
public SqlPagingQueryUtils()
-
-
Method Details
-
generateLimitSqlQuery
public static String generateLimitSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String limitClause) Generate SQL query string using a LIMIT clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsremainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)limitClause
- the implementation specific limit clause to be used- Returns:
- the generated query
-
generateLimitGroupedSqlQuery
@Deprecated public static String generateLimitGroupedSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String limitClause) Deprecated.as of v5.0 in favor ofgenerateLimitGroupedSqlQuery(AbstractSqlPagingQueryProvider, java.lang.String)
Generate SQL query string using a LIMIT clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsremainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)limitClause
- the implementation specific limit clause to be used- Returns:
- the generated query
-
generateLimitGroupedSqlQuery
public static String generateLimitGroupedSqlQuery(AbstractSqlPagingQueryProvider provider, String limitClause) Generate SQL query string using a LIMIT clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificslimitClause
- the implementation specific limit clause to be used- Returns:
- the generated query
-
generateTopSqlQuery
public static String generateTopSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String topClause) Generate SQL query string using a TOP clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsremainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)topClause
- the implementation specific top clause to be used- Returns:
- the generated query
-
generateGroupedTopSqlQuery
public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String topClause) Generate SQL query string using a TOP clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsremainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)topClause
- the implementation specific top clause to be used- Returns:
- the generated query
-
generateRowNumSqlQuery
public static String generateRowNumSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery, String rowNumClause) Generate SQL query string using a ROW_NUM condition- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsremainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)rowNumClause
- the implementation specific row num clause to be used- Returns:
- the generated query
-
generateRowNumSqlQuery
public static String generateRowNumSqlQuery(AbstractSqlPagingQueryProvider provider, String selectClause, boolean remainingPageQuery, String rowNumClause) Generate SQL query string using a ROW_NUM condition- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificsselectClause
-String
containing the select portion of the query.remainingPageQuery
- is this query for the remaining pages (true) as opposed to the first page (false)rowNumClause
- the implementation specific row num clause to be used- Returns:
- the generated query
-
generateRowNumSqlQueryWithNesting
public static String generateRowNumSqlQueryWithNesting(AbstractSqlPagingQueryProvider provider, String selectClause, boolean remainingPageQuery, String rowNumClause) -
generateRowNumSqlQueryWithNesting
public static String generateRowNumSqlQueryWithNesting(AbstractSqlPagingQueryProvider provider, String innerSelectClause, String outerSelectClause, boolean remainingPageQuery, String rowNumClause) -
generateLimitJumpToQuery
public static String generateLimitJumpToQuery(AbstractSqlPagingQueryProvider provider, String limitClause) Generate SQL query string using a LIMIT clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificslimitClause
- the implementation specific top clause to be used- Returns:
- the generated query
-
generateTopJumpToQuery
public static String generateTopJumpToQuery(AbstractSqlPagingQueryProvider provider, String topClause) Generate SQL query string using a TOP clause- Parameters:
provider
-AbstractSqlPagingQueryProvider
providing the implementation specificstopClause
- the implementation specific top clause to be used- Returns:
- the generated query
-
buildSortClause
Generates ORDER BY attributes based on the sort keys.- Parameters:
provider
- theAbstractSqlPagingQueryProvider
to be used for used for pagination.- Returns:
- a String that can be appended to an ORDER BY clause.
-
buildSortClause
Generates ORDER BY attributes based on the sort keys. -
buildSortConditions
Appends the where conditions required to query for the subsequent pages.- Parameters:
provider
- theAbstractSqlPagingQueryProvider
to be used for pagination.sql
-StringBuilder
containing the sql to be used for the query.
-
generateLimitGroupedSqlQuery(AbstractSqlPagingQueryProvider, java.lang.String)