diff --git a/src/main/java/org/omnifaces/persistence/Provider.java b/src/main/java/org/omnifaces/persistence/Provider.java index 81b6888..bed9f3a 100644 --- a/src/main/java/org/omnifaces/persistence/Provider.java +++ b/src/main/java/org/omnifaces/persistence/Provider.java @@ -63,6 +63,9 @@ public String getDialectName(EntityManagerFactory entityManagerFactory) { @Override public boolean isAggregation(Expression expression) { + if (HIBERNATE_6_0_0_AGGREGATE_FUNCTION.isPresent()) { + return HIBERNATE_6_0_0_AGGREGATE_FUNCTION.get().isInstance(expression); + } return (HIBERNATE_BASIC_FUNCTION_EXPRESSION.get().isInstance(expression) && (boolean) invokeMethod(expression, "isAggregation")) || (HIBERNATE_COMPARISON_PREDICATE.get().isInstance(expression) && (isAggregation(invokeMethod(expression, "getLeftHandOperand")) || isAggregation(invokeMethod(expression, "getRightHandOperand")))); } @@ -152,6 +155,7 @@ public boolean isOneToMany(Attribute attribute) { private static final Optional> HIBERNATE_4_3_0_BASIC_FUNCTION_EXPRESSION = findClass("org.hibernate.jpa.criteria.expression.function.BasicFunctionExpression"); private static final Optional> HIBERNATE_5_2_0_BASIC_FUNCTION_EXPRESSION = findClass("org.hibernate.query.criteria.internal.expression.function.BasicFunctionExpression"); private static final Optional> HIBERNATE_BASIC_FUNCTION_EXPRESSION = Stream.of(HIBERNATE_5_2_0_BASIC_FUNCTION_EXPRESSION, HIBERNATE_4_3_0_BASIC_FUNCTION_EXPRESSION, HIBERNATE_3_5_0_BASIC_FUNCTION_EXPRESSION).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); + private static final Optional> HIBERNATE_6_0_0_AGGREGATE_FUNCTION = findClass("org.hibernate.query.sqm.function.SelfRenderingSqmAggregateFunction"); private static final Optional> HIBERNATE_3_5_0_COMPARISON_PREDICATE = findClass("org.hibernate.ejb.criteria.predicate.ComparisonPredicate"); private static final Optional> HIBERNATE_4_3_0_COMPARISON_PREDICATE = findClass("org.hibernate.jpa.criteria.predicate.ComparisonPredicate"); private static final Optional> HIBERNATE_5_2_0_COMPARISON_PREDICATE = findClass("org.hibernate.query.criteria.internal.predicate.ComparisonPredicate");