We're updating the issue view to help you get more done. 

Incorrect generated SQL for embedded map in entity parent

Description

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.

Environment

None

Status

Assignee

Unassigned

Reporter

Jon Kranes

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.6
4.3.8

Priority

Major