Allow dereferencing of KEY() path

Description

As mentioned in HHH-10537, The JPA spec contains examples of KEY() path dereferencing which is currently not allowed in Hibernate. This can be especially useful in cases where the map key is an entity since

1 SELECT KEY(map) FROM ...

would fetch the whole key but it might be desirable to select only a specific property of the key entity e.g.:

1 SELECT KEY(map).name FROM ...

Note that the selecting KEY(map).id is a special case for optimization since there is no need for an extra join in this case - the id can be selected from the join table.

Attached is a test project that contains two basic tests, one for the id case and one for referencing a basic property. Further tests should also cover other types of paths like associations etc.

Environment

None

Status

Assignee

Christian Beikov

Reporter

Moritz Becker

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.2.0.Final
5.0.0.Final
5.1.0
5.2.0
4.3.0.Final

Priority

Major