HHH-18077 extremely minor cleanup after fix
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
5512281a5e
commit
dc0ca6382f
|
@ -181,29 +181,33 @@ 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) {
|
if ( keyedPage.getKeyInterpretation() == KEY_OF_FIRST_ON_NEXT_PAGE ) {
|
||||||
|
// the results come in reverse order
|
||||||
return !results.isEmpty()
|
return !results.isEmpty()
|
||||||
? keyedPage.nextPage( results.get(0).getKey() )
|
? keyedPage.nextPage( results.get(0).getKey() )
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
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() )
|
||||||
: null;
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if ( keyedPage.getKeyInterpretation() == KEY_OF_FIRST_ON_NEXT_PAGE ) {
|
||||||
|
// the results come in reverse order
|
||||||
final int pageSize = keyedPage.getPage().getSize();
|
final int pageSize = keyedPage.getPage().getSize();
|
||||||
return results.size() == pageSize + 1
|
return results.size() == pageSize + 1
|
||||||
? keyedPage.previousPage( results.get(pageSize - 1).getKey() )
|
? keyedPage.previousPage( results.get(pageSize - 1).getKey() )
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return !results.isEmpty()
|
return !results.isEmpty()
|
||||||
? keyedPage.previousPage( results.get(0).getKey() )
|
? keyedPage.previousPage( results.get(0).getKey() )
|
||||||
: null;
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Class<R> getExpectedResultType();
|
public abstract Class<R> getExpectedResultType();
|
||||||
|
|
|
@ -47,6 +47,7 @@ class KeyedResult<R> {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_OF_FIRST_ON_NEXT_PAGE:
|
case KEY_OF_FIRST_ON_NEXT_PAGE:
|
||||||
|
// the results come in reverse order
|
||||||
for (int i = pageSize-1; i>=0; i--) {
|
for (int i = pageSize-1; i>=0; i--) {
|
||||||
if (i < size) {
|
if (i < size) {
|
||||||
resultList.add( executed.get(i).getResult() );
|
resultList.add( executed.get(i).getResult() );
|
||||||
|
|
Loading…
Reference in New Issue