If an entity is requested by a distinct query and the result should be ordered by an attribute of a joined entity e.g. of an OneToMany relation the query created by hibernate does not contain the order attribute in the result list. Databases like postgres and h2 can not process this query. The reason why is decribed in places like this: https://github.com/h2database/h2database/issues/408#issuecomment-262641613
This functinality functionality is essential for many cases where complex data is filtered and ordered in paged tables with complex queries. Without distinct there is no problem, as soon as distinct is necessary and can't be avoided the query fails. |
|