Remove unused parameter in SqlPagingQueryUtils#generateGroupedTopSqlQuery

This commit is contained in:
Mahmoud Ben Hassine
2024-05-27 11:26:07 +02:00
parent ea08a4a3f6
commit b3b4310a5f
4 changed files with 35 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.springframework.util.StringUtils;
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
@@ -37,7 +38,7 @@ public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
@Override
public String generateRemainingPagesQuery(int pageSize) {
if (StringUtils.hasText(getGroupClause())) {
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
}
else {
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));

View File

@@ -144,7 +144,10 @@ public abstract class SqlPagingQueryUtils {
* to the first page (false)
* @param topClause the implementation specific top clause to be used
* @return the generated query
* @deprecated since v5.2 in favor of
* {@link #generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider, String)}
*/
@Deprecated
public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider provider, boolean remainingPageQuery,
String topClause) {
StringBuilder sql = new StringBuilder();
@@ -161,6 +164,29 @@ public abstract class SqlPagingQueryUtils {
return sql.toString();
}
/**
* Generate SQL query string using a TOP clause
* @param provider {@link AbstractSqlPagingQueryProvider} providing the implementation
* specifics
* @param topClause the implementation specific top clause to be used
* @return the generated query
* @since 5.2
*/
public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider provider, String topClause) {
StringBuilder sql = new StringBuilder();
sql.append("SELECT ").append(topClause).append(" * FROM (");
sql.append("SELECT ").append(provider.getSelectClause());
sql.append(" FROM ").append(provider.getFromClause());
sql.append(provider.getWhereClause() == null ? "" : " WHERE " + provider.getWhereClause());
buildGroupByClause(provider, sql);
sql.append(") AS MAIN_QRY ");
sql.append("WHERE ");
buildSortConditions(provider, sql);
sql.append(" ORDER BY ").append(buildSortClause(provider));
return sql.toString();
}
/**
* Generate SQL query string using a ROW_NUM condition
* @param provider {@link AbstractSqlPagingQueryProvider} providing the implementation

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.springframework.util.StringUtils;
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class SqlServerPagingQueryProvider extends SqlWindowingPagingQueryProvider {
@@ -37,7 +38,7 @@ public class SqlServerPagingQueryProvider extends SqlWindowingPagingQueryProvide
@Override
public String generateRemainingPagesQuery(int pageSize) {
if (StringUtils.hasText(getGroupClause())) {
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
}
else {
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2012 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.springframework.util.StringUtils;
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class SybasePagingQueryProvider extends SqlWindowingPagingQueryProvider {
@@ -37,7 +38,7 @@ public class SybasePagingQueryProvider extends SqlWindowingPagingQueryProvider {
@Override
public String generateRemainingPagesQuery(int pageSize) {
if (StringUtils.hasText(getGroupClause())) {
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, true, buildTopClause(pageSize));
return SqlPagingQueryUtils.generateGroupedTopSqlQuery(this, buildTopClause(pageSize));
}
else {
return SqlPagingQueryUtils.generateTopSqlQuery(this, true, buildTopClause(pageSize));