Skip to content

Commit

Permalink
Bump versions to at least Java 17, JEE 10, Hibernate 6; fixed failing
Browse files Browse the repository at this point in the history
logic and tests caused by changes in Hibernate 6; catch up Java 17
features such as var and instanceof var
  • Loading branch information
BalusC committed Sep 4, 2024
1 parent 3561f98 commit 7a8549f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/omnifaces/persistence/Provider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"))));
}
Expand Down Expand Up @@ -152,6 +155,7 @@ public boolean isOneToMany(Attribute<?, ?> attribute) {
private static final Optional<Class<Object>> HIBERNATE_4_3_0_BASIC_FUNCTION_EXPRESSION = findClass("org.hibernate.jpa.criteria.expression.function.BasicFunctionExpression");
private static final Optional<Class<Object>> HIBERNATE_5_2_0_BASIC_FUNCTION_EXPRESSION = findClass("org.hibernate.query.criteria.internal.expression.function.BasicFunctionExpression");
private static final Optional<Class<Object>> 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<Class<Object>> HIBERNATE_6_0_0_AGGREGATE_FUNCTION = findClass("org.hibernate.query.sqm.function.SelfRenderingSqmAggregateFunction");
private static final Optional<Class<Object>> HIBERNATE_3_5_0_COMPARISON_PREDICATE = findClass("org.hibernate.ejb.criteria.predicate.ComparisonPredicate");
private static final Optional<Class<Object>> HIBERNATE_4_3_0_COMPARISON_PREDICATE = findClass("org.hibernate.jpa.criteria.predicate.ComparisonPredicate");
private static final Optional<Class<Object>> HIBERNATE_5_2_0_COMPARISON_PREDICATE = findClass("org.hibernate.query.criteria.internal.predicate.ComparisonPredicate");
Expand Down

0 comments on commit 7a8549f

Please sign in to comment.