HHH-18077 Fix key selection paging to previous pages

This commit is contained in:
Jere Penttinen 2024-05-07 15:19:01 +03:00 committed by Gavin King
parent eef5cc2536
commit 4ae64eeb3f
1 changed files with 13 additions and 0 deletions

View File

@ -181,6 +181,12 @@ abstract class AbstractSqmSelectionQuery<R> extends AbstractSelectionQuery<R> {
} }
private static <R> KeyedPage<R> nextPage(KeyedPage<R> keyedPage, List<KeyedResult<R>> results) { private static <R> KeyedPage<R> nextPage(KeyedPage<R> keyedPage, List<KeyedResult<R>> results) {
if (keyedPage.getKeyInterpretation() == KEY_OF_FIRST_ON_NEXT_PAGE) {
return !results.isEmpty()
? keyedPage.nextPage( results.get(0).getKey() )
: null;
}
final int pageSize = keyedPage.getPage().getSize(); final int pageSize = keyedPage.getPage().getSize();
return results.size() == pageSize + 1 return results.size() == pageSize + 1
? keyedPage.nextPage( results.get(pageSize - 1).getKey() ) ? keyedPage.nextPage( results.get(pageSize - 1).getKey() )
@ -188,6 +194,13 @@ abstract class AbstractSqmSelectionQuery<R> extends AbstractSelectionQuery<R> {
} }
private static <R> KeyedPage<R> previousPage(KeyedPage<R> keyedPage, List<KeyedResult<R>> results) { private static <R> KeyedPage<R> previousPage(KeyedPage<R> keyedPage, List<KeyedResult<R>> results) {
if (keyedPage.getKeyInterpretation() == KEY_OF_FIRST_ON_NEXT_PAGE) {
final int pageSize = keyedPage.getPage().getSize();
return results.size() == pageSize + 1
? keyedPage.previousPage( results.get(pageSize - 1).getKey() )
: null;
}
return !results.isEmpty() return !results.isEmpty()
? keyedPage.previousPage( results.get(0).getKey() ) ? keyedPage.previousPage( results.get(0).getKey() )
: null; : null;