Skip to content

Commit

Permalink
Fix Oracle test missing order by expression in select distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and beikov committed May 27, 2024
1 parent 7b9ec40 commit 4a372fa
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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)
Expand All @@ -42,11 +43,12 @@ public void testLimit(SessionFactoryScope scope) {
final Root<Person> personRoot = criteriaquery.from( Person.class );
final Join<Person, Travel> travels = personRoot.join( "travels", JoinType.LEFT );

criteriaquery.select( personRoot ).
final Path<String> 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<Person> createQuery = session.createQuery( criteriaquery );

Expand Down

0 comments on commit 4a372fa

Please sign in to comment.