From b88d496c76b251644f33a285a9c6a35c4f5f7c20 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Fri, 29 Mar 2024 10:22:13 +0100 Subject: [PATCH] tolerate badly-typed PageRequest parameters as required by Jakarta Data TCK Signed-off-by: Gavin King --- .../hibernate/processor/annotation/AbstractQueryMethod.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java index 4266e09ee4..a3326fb9fe 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AbstractQueryMethod.java @@ -378,10 +378,12 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod { "\t\t\t\t\t\t.collect(toList());\n" + "\t\tvar _page =\n" + "\t\t\t\tPageRequest.of(Entity.class)\n" + - "\t\t\t\t\t\t.sortBy(pageRequest.sorts())\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\treturn new CursoredPageRecord<>(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" + + //SHOULD BE new CursoredPageRecord<> + "\t\treturn new CursoredPageRecord(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" + "\t\t\t\t_results.isLastPage() ? null : _page.afterKey(_results.getNextPage().getKey().toArray()),\n" + "\t\t\t\t_results.isFirstPage() ? null : _page.beforeKey(_results.getPreviousPage().getKey().toArray()));";