simplify the generated code for cursored pagination
as suggested by Nathan Rauh Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
6beb011369
commit
f6add9dbbb
|
@ -376,22 +376,10 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod {
|
||||||
"\t\t\t\t\t\t.stream()\n" +
|
"\t\t\t\t\t\t.stream()\n" +
|
||||||
"\t\t\t\t\t\t.map(_key -> Cursor.forKey(_key.toArray()))\n" +
|
"\t\t\t\t\t\t.map(_key -> Cursor.forKey(_key.toArray()))\n" +
|
||||||
"\t\t\t\t\t\t.collect(toList());\n" +
|
"\t\t\t\t\t\t.collect(toList());\n" +
|
||||||
"\t\tvar _next =\n" +
|
|
||||||
"\t\t\t\tPageRequest.of(Entity.class)\n" +
|
|
||||||
//SHOULD NOT have cast to raw Iterable
|
|
||||||
"\t\t\t\t\t\t.sortBy((Iterable) pageRequest.sorts())\n" +
|
|
||||||
"\t\t\t\t\t\t.size(pageRequest.size())\n" +
|
|
||||||
"\t\t\t\t\t\t.page(pageRequest.page() + 1);\n" +
|
|
||||||
"\t\tvar _last =\n" +
|
|
||||||
"\t\t\t\tPageRequest.of(Entity.class)\n" +
|
|
||||||
//SHOULD NOT have cast to raw Iterable
|
|
||||||
"\t\t\t\t\t\t.sortBy((Iterable) pageRequest.sorts())\n" +
|
|
||||||
"\t\t\t\t\t\t.size(pageRequest.size())\n" +
|
|
||||||
"\t\t\t\t\t\t.page(pageRequest.page() - 1);\n" +
|
|
||||||
//SHOULD BE new CursoredPageRecord<>
|
//SHOULD BE new CursoredPageRecord<>
|
||||||
"\t\treturn new CursoredPageRecord(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" +
|
"\t\treturn new CursoredPageRecord(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" +
|
||||||
"\t\t\t\t_results.isLastPage() ? null : _next.afterKey(_results.getNextPage().getKey().toArray()),\n" +
|
"\t\t\t\t_results.isLastPage() ? null : pageRequest.page(pageRequest.page()+1).afterCursor(_cursors.get(_cursors.size()-1)),\n" +
|
||||||
"\t\t\t\t_results.isFirstPage() ? null : _last.beforeKey(_results.getPreviousPage().getKey().toArray()));";
|
"\t\t\t\t_results.isFirstPage() ? null : pageRequest.page(pageRequest.page()-1).beforeCursor(_cursors.get(0)));";
|
||||||
|
|
||||||
static final String MAKE_KEYED_PAGE
|
static final String MAKE_KEYED_PAGE
|
||||||
= "\tvar _unkeyedPage =\n" +
|
= "\tvar _unkeyedPage =\n" +
|
||||||
|
|
Loading…
Reference in New Issue