Skip to content

Commit b3b4310

Browse files
committed
Remove unused parameter in SqlPagingQueryUtils#generateGroupedTopSqlQuery
1 parent ea08a4a commit b3b4310

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/HsqlPagingQueryProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2022 the original author or authors.
2+
* Copyright 2006-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
*
2626
* @author Thomas Risberg
2727
* @author Michael Minella
28+
* @author Mahmoud Ben Hassine
2829
* @since 2.0
2930
*/
3031
public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
@@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
3738
@Override
3839
public String generateRemainingPagesQuery(int pageSize) {
3940
if (StringUtils.hasText(getGroupClause())) {
40-
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
41+
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
4142
}
4243
else {
4344
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlPagingQueryUtils.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ public static String generateTopSqlQuery(AbstractSqlPagingQueryProvider provider
144144
* to the first page (false)
145145
* @param topClause the implementation specific top clause to be used
146146
* @return the generated query
147+
* @deprecated since v5.2 in favor of
148+
* {@link #generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider, String)}
147149
*/
150+
@Deprecated
148151
public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery,
149152
String topClause) {
150153
StringBuilder sql = new StringBuilder();
@@ -161,6 +164,29 @@ public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider p
161164
return sql.toString();
162165
}
163166

167+
/**
168+
* Generate SQL query string using a TOP clause
169+
* @param provider {@link AbstractSqlPagingQueryProvider} providing the implementation
170+
* specifics
171+
* @param topClause the implementation specific top clause to be used
172+
* @return the generated query
173+
* @since 5.2
174+
*/
175+
public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider provider, String topClause) {
176+
StringBuilder sql = new StringBuilder();
177+
sql.append("SELECT ").append(topClause).append(" * FROM (");
178+
sql.append("SELECT ").append(provider.getSelectClause());
179+
sql.append(" FROM ").append(provider.getFromClause());
180+
sql.append(provider.getWhereClause() == null ? "" : " WHERE " + provider.getWhereClause());
181+
buildGroupByClause(provider, sql);
182+
sql.append(") AS MAIN_QRY ");
183+
sql.append("WHERE ");
184+
buildSortConditions(provider, sql);
185+
sql.append(" ORDER BY ").append(buildSortClause(provider));
186+
187+
return sql.toString();
188+
}
189+
164190
/**
165191
* Generate SQL query string using a ROW_NUM condition
166192
* @param provider {@link AbstractSqlPagingQueryProvider} providing the implementation

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SqlServerPagingQueryProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2012 the original author or authors.
2+
* Copyright 2006-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
*
2626
* @author Thomas Risberg
2727
* @author Michael Minella
28+
* @author Mahmoud Ben Hassine
2829
* @since 2.0
2930
*/
3031
public class SqlServerPagingQueryProvider extends SqlWindowingPagingQueryProvider {
@@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
3738
@Override
3839
public String generateRemainingPagesQuery(int pageSize) {
3940
if (StringUtils.hasText(getGroupClause())) {
40-
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
41+
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
4142
}
4243
else {
4344
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/SybasePagingQueryProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2012 the original author or authors.
2+
* Copyright 2006-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
*
2626
* @author Thomas Risberg
2727
* @author Michael Minella
28+
* @author Mahmoud Ben Hassine
2829
* @since 2.0
2930
*/
3031
public class SybasePagingQueryProvider extends SqlWindowingPagingQueryProvider {
@@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
3738
@Override
3839
public String generateRemainingPagesQuery(int pageSize) {
3940
if (StringUtils.hasText(getGroupClause())) {
40-
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
41+
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
4142
}
4243
else {
4344
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));

0 commit comments

Comments
 (0)