Consider three simple entities:
{code:java}@Entity public class RootEntity {
@Id private Long id;
private String name; }
@Entity public class UnrelatedEntity {
@Id private Long id;
private String name;
private String someValue; }
@Entity public class OtherEntity {
@Id private Long id; }{code}
Execute a query which has two roots and one unrelated join:
{code:java}entityManager.createQuery(""" select r.name, u.someValue, oe.id from RootEntity r, OtherEntity oe left join UnrelatedEntity u on u.name = r.name """).getResultList();{code}
With Hibernate 5.x, the query is executed successfully.
With Hibernate 6.x, the query fails:
{noformat}java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: SqmQualifiedJoin predicate referred to SqmRoot [com.example.demo.RootEntity(r)] other than the join's root [com.example.demo.UnrelatedEntity(u)]{noformat}
If {{OtherEntity oe}} is removed from {{from}} clause, the query is executed successfully.
Please see reproducer:
[^hibernate-orm-6-HHH-17028.zip]
This bug is blocking our migration to Hibernate 6 (and consequently to Spring Boot 3).
Please let me know if you need a full-fledged reproducer project. |
|