JPA 2.0 subselect / subquery in order by condition with api criteria

I want to use JPA 2.0 api criteria to create an order by clause with a subquery. I know that you can do this in plain SQL, but can it be matched against api criteria? Can someone please provide an example code?

Example:

Order(name, address) // table1 OrderPriority(address, priority) // table2 priority by address select o from Order o order by (select p.priority from OrderPriority p where p.address = o.address) 
+4
source share
1 answer

Criteria API queries are converted to JPQL, and apparently the subqueries in the order by clause are not supported in JPQL.

A similar StackOverflow answer can be found here .

+1
source

Source: https://habr.com/ru/post/1013334/


All Articles