MappingException when @MapKeyColumn refers to a column mapped in embeddable map value

Description

Map<Basic, Embeddable> does not work, when the map key is a persistent field of the value. The map key shall not be represented as a separate table column, this is why the example uses @MapKey and not @MapKeyColumn.

Example:

Hibernate appears to expect an Entity as map value:

org.hibernate.AnnotationException: Associated class not found: LocalizedString

Detailed discussion of this use case:
http://hwellmann.blogspot.com/2010/07/jpa-20-mapping-map.html

Activity

Show:

Ka WuFebruary 5, 2019 at 6:53 PM

Former userFebruary 5, 2019 at 6:14 PM

, this issue has already been closed. If you are still seeing problems in 5.4, then please open a new issue and attach a test case that reproduces the issue. Test templates can be found at https://github.com/hibernate/hibernate-test-case-templates

Ka WuFebruary 5, 2019 at 3:17 PM

Pardon me, but this doesn't appear to be fixed.

Here's a problem description from 2018: https://stackoverflow.com/questions/49940382/annotationexception-when-mapkey-refers-to-a-column-mapped-in-embeddable-map-val

I am having exactly the same problem in 2019 (Hibernate 5.3.6.Final):

Fails with:

Former userJuly 14, 2016 at 11:51 PM

Fixed in master, 5.1, and 5.0 branches.

Former userJuly 13, 2016 at 7:45 PM

, thanks for your fix. II believe it will work when the column in the embeddable is annotated with:

@Column( insertable = false, updatable = false ),

but it doesn't work if the Map is annotated with:

@MapKeyColumn(name = "language", insertable = false, updatable = false)

The code checking for duplication needs to exclude non-insertable, non-updatable columns from the map key as well as the map value.

Currently, SimpleValue does not retain information about insertable or updatable columns. I plan to extend SimpleValue to do that.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

Created July 19, 2010 at 12:23 PM
Updated February 5, 2019 at 6:53 PM
Resolved July 14, 2016 at 11:51 PM