Hibernate generates an invalid SQL for the case below, that basically resembles this:
(duplicate null precedence at the end)
The issue is constantly reproducible with a simple setup where you have 2 entities with a @OneToMany relation with @OrderBy annotation on the collection. Then at query time specify that relation in the entity graph hint.
I'm attaching the test scenario, it has 2 almost identical test cases:
1. With entity graph hint: Fails
2. Without entity graph hint: Succeeds
Please let me know if there is any other detail I could specify to help.