|
Given an entity class MyEntity linked to a many-one parent MyEntityParent, where the parent contains an embedded collection Map, for example (getters and setters removed here)
@Entity public class MyEntity { @Id @GeneratedValue private Long id; private String name; @ManyToOne private MyEntityParent parent; }
@Entity public class MyEntityParent { @Id @GeneratedValue private Long id; private String name; @ElementCollection private Map<String, String> embeddedMap; }
Hibernate fails to generate correct SQL from the following JPQL:
select e.id, VALUE(map) from MyEntity e left join e.parent.embeddedMap map on KEY(map)='key'
The resulting generated SQL is invalid and results in an exception.
Note that this issue can be worked around by changing the initial query to:
select e.id, VALUE(map) from MyEntity e join e.parent p left join p.embeddedMap map on KEY(map)='key'
which will generate correct SQL.
The attached unit test demonstrates this issue.
|