AnnotationException when @MapKey refers to a column mapped in @Embeddable: @ElementCollection (one to many embeddables)

Description

There's a problem mapping an @Embeddable as @ElementCollection (one to many) with an Enum as @MapKey (Hibernate 5.3.6.Final):

This fails with:

Here's another use case:

https://stackoverflow.com/questions/49940382/annotationexception-when-mapkey-refers-to-a-column-mapped-in-embeddable-map-val

Environment

Hibernate 5.3.6, MySQL 8.0, WildFly 14.0.1.Final

Activity

Show:
Ka Wu
February 5, 2019, 7:08 PM

I'm pretty sure that the case described in https://hibernate.atlassian.net/browse/HHH-5393 can be used, you just have to replace `@MapKeyColumn(name="language")` with `@MapKey(name="language")`...

Ka Wu
February 5, 2019, 7:34 PM

Still the same exception for Hibernate 5.4.1.Final:

Gail Badner
February 7, 2019, 11:40 PM

, documentation for @MapKey says:

"The MapKey annotation is used to specify the map key for associations of type java.util.Map
when the map key is itself the primary key or a persistent field or property of the entity that is the value
of the map. "

PhoneNumber is an embeddable, not an entity. You should be using @MapKeyColumn instead.

Assignee

Gail Badner

Reporter

Ka Wu

Fix versions

None

backPortable

Backport?

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure