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
would fetch the whole key but it might be desirable to select only a specific property of the key entity e.g.:
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. |