Please, refer to this Repository that contains a project that reproduces the problem: https://github.com/Andremoniy/hibernate-6-order-by-issue Basically, under certain conditions the column name provided in the OrderBy annotation is not transformed to the physical name of the column in the databse. This is a combination of the three different conditions:
- The field used in the OrderBy should be a part of a composite key on the mapped entity. In our case this is DepartmentId composite key:
- The field used in the OrderBy entity should contain more than a word in its name (if we rename departmentCode into code, the issue goes away).
- There should be an HQL query that uses LEFT JOIN FETCH on the problematic entity.
|