Code:
Is not supported use a subquery as sort ?
According to
Hibernate User Guide, which you should read it, this is what's supported in the HQL ORDER BY clause:
Quote:
The types of expressions considered valid as part of the ORDER BY clause include:
- state fields
- component/embeddable attributes
- scalar expressions such as arithmetic operations, functions, etc.
- identification variable declared in the select clause for any of the previous expression types
So, it does not support nested selects.
Quote:
Oracle DB and SAP Hana support such syntax (I'm working on Oracle).
Just because Hibernate offers HQL, it does not mean you have to use it for everything. Otherwise, why do you think Hibernate and JPA allow you to run Native SQL queries?
HQL is suitable to fetch entities that you plan on modifying. Otherwise,
just use DTO projections. You can use the
ResultTransformer to build any type of DTO projection you like (e.g. trees, graphs, etc)
So, just write the query in SQL.