diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/AbstractSqmPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/AbstractSqmPredicate.java index 1685d8d430..16ba1a5ff3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/AbstractSqmPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/AbstractSqmPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.query.sqm.tree.predicate; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import org.hibernate.query.sqm.NodeBuilder; @@ -33,7 +33,7 @@ public abstract class AbstractSqmPredicate extends AbstractSqmExpression> getExpressions() { /// most predicates do not have sub-predicates - return Collections.emptyList(); + return new ArrayList<>(0); } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmBooleanExpressionPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmBooleanExpressionPredicate.java index 2038322ab7..f860b896f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmBooleanExpressionPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmBooleanExpressionPredicate.java @@ -6,14 +6,13 @@ */ package org.hibernate.query.sqm.tree.predicate; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.expression.SqmExpression; -import org.hibernate.sql.ast.tree.predicate.NegatedPredicate; import jakarta.persistence.criteria.Expression; @@ -73,7 +72,9 @@ public class SqmBooleanExpressionPredicate extends AbstractNegatableSqmPredicate @Override public List> getExpressions() { - return Collections.singletonList( booleanExpression ); + final List> expressions = new ArrayList<>( 1 ); + expressions.add( booleanExpression ); + return expressions; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmGroupedPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmGroupedPredicate.java index af4706e88c..0ae9a64ef6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmGroupedPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmGroupedPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.query.sqm.tree.predicate; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import org.hibernate.query.sqm.NodeBuilder; @@ -59,7 +59,9 @@ public class SqmGroupedPredicate extends AbstractSqmPredicate { @Override public List> getExpressions() { - return Collections.singletonList( subPredicate ); + final List> expressions = new ArrayList<>( 1 ); + expressions.add( subPredicate ); + return expressions; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmJunctionPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmJunctionPredicate.java index 31525c1b69..343f07a65c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmJunctionPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmJunctionPredicate.java @@ -11,9 +11,7 @@ import java.util.List; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; -import org.hibernate.query.sqm.SqmExpressible; import org.hibernate.query.sqm.tree.SqmCopyContext; -import org.hibernate.sql.ast.tree.predicate.Junction; import jakarta.persistence.criteria.Expression; @@ -88,8 +86,7 @@ public class SqmJunctionPredicate extends AbstractSqmPredicate { @Override public List> getExpressions() { - //noinspection unchecked - return (List>) (List) predicates; + return new ArrayList<>( predicates ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmNegatedPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmNegatedPredicate.java index e2bc15e51c..92e3e500b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmNegatedPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/predicate/SqmNegatedPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.query.sqm.tree.predicate; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import org.hibernate.query.sqm.NodeBuilder; @@ -58,7 +58,9 @@ public class SqmNegatedPredicate extends AbstractNegatableSqmPredicate { @Override public List> getExpressions() { - return Collections.singletonList( wrappedPredicate ); + final List> expressions = new ArrayList<>( 1 ); + expressions.add( wrappedPredicate ); + return expressions; } @Override