From 4c9b8b1e04d9413e0ab908edd4583990f8120646 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 6 May 2024 10:57:38 +0200 Subject: [PATCH] Fix Oracle test missing order by expression in select distinct --- .../org/hibernate/orm/test/limit/Oracle12LimitTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/limit/Oracle12LimitTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/limit/Oracle12LimitTest.java index 82b1720434..f19128709b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/limit/Oracle12LimitTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/limit/Oracle12LimitTest.java @@ -19,6 +19,7 @@ import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.Join; import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; import jakarta.persistence.criteria.Root; @RequiresDialect(value = OracleDialect.class, majorVersion = 12) @@ -42,11 +43,12 @@ public class Oracle12LimitTest { final Root personRoot = criteriaquery.from( Person.class ); final Join travels = personRoot.join( "travels", JoinType.LEFT ); - criteriaquery.select( personRoot ). + final Path destination = travels.get( "destination" ); + criteriaquery.multiselect( personRoot, destination ). where( criteriabuilder.or( criteriabuilder.equal( personRoot.get( "name" ), "A" ) ) ) .distinct( true ); - criteriaquery.orderBy( criteriabuilder.desc( criteriabuilder.upper( travels.get( "destination" ) ) ) ); + criteriaquery.orderBy( criteriabuilder.desc( criteriabuilder.upper( destination ) ) ); final TypedQuery createQuery = session.createQuery( criteriaquery );