You are right, the tested change is incorrect, though the test I built shows that the query built by hibernate without the change is also incorrect for both the current version (6.2) as well as the last 5.x version of Hibernate.