Skip to content

Commit

Permalink
Remove unused parameter in SqlPagingQueryUtils#generateGroupedTopSqlQ…
Browse files Browse the repository at this point in the history
…uery
  • Loading branch information
fmbenhassine committed May 27, 2024
1 parent ea08a4a commit b3b4310
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,6 +25,7 @@
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider {
Expand All @@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
@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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ public static String generateTopSqlQuery(AbstractSqlPagingQueryProvider provider
* 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();
Expand All @@ -161,6 +164,29 @@ public static String generateGroupedTopSqlQuery(AbstractSqlPagingQueryProvider p
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,6 +25,7 @@
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class SqlServerPagingQueryProvider extends SqlWindowingPagingQueryProvider {
Expand All @@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
@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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,6 +25,7 @@
*
* @author Thomas Risberg
* @author Michael Minella
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class SybasePagingQueryProvider extends SqlWindowingPagingQueryProvider {
Expand All @@ -37,7 +38,7 @@ public String generateFirstPageQuery(int pageSize) {
@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));
Expand Down

0 comments on commit b3b4310

Please sign in to comment.