Hi, I just ran the test case, and there's something odd indeed: as Florian said, @MapKeyJoinColumn in embeddables seem to be completely ignored when the (embedded) association is overridden using @AssociationOverride. When not using @AssociationOverride, everything works fine.
Vlad, do you think this could be a bug? It seems odd, but maybe I'm missing something. I forked the test to make it run on an embedded H2 instance, which should be easier to run quickly: https://github.com/yrodiere/hibernate-test-case Yoann Rodière <yo...@hibernate.org> Hibernate NoORM Team On 23 November 2016 at 17:09, Florian Lacreuse <florian.lacre...@smile.fr> wrote: > We didn't know about the JPA spec on this particular detail, thanks for > the precision. > > Nonetheless, we don't want to override the @MapKeyJoinColumn, we just > want the annotation to be taken into consideration while we use > @AssociationOverride to override something else. > > We have updated the test case > (https://github.com/florianlacreuse/hibernate-test-case > <https://github.com/florianlacreuse/hibernate-test-case>). In Employee > entity we use the same embeddable twice, so we have to use > @AssociationOverride to name the two join tables. In both tables, the > column related to the key has the default name ("experiences_KEY") > instead of the one provided by the @MapKeyJoinColumn ("jobtitle_id"). > > To resume, we understrand that it's not possible to override > @MapKeyJoinColumn but @MapKeyJoinColumn should not be ignored. > > In Employee entity you can also find a third attribute with the same > embeddable but without any @AssociationOverride. In this case, > @MapKeyJoinColumn works as expected. > > Kind regards, > > Logo <http://www.smile.fr/> > > 151 boulevard Stalingrad > 69100 Villeurbanne > www.smile.fr <http://www.smile.fr/> > *Florian LACREUSE* > Ingénieur d'études et développement > Pôle Développement Spécifique Java > Open Wide - Systèmes d'Information > Email : florian.lacre...@smile.fr <mailto:florian.lacre...@smile.fr> > > > Le 23/11/2016 à 16:08, Vlad Mihalcea a écrit : > > The JPA spec does not specify a way to override the MapKeyJoinColumn. > > You can override the association, like the JoinColumn for a ManyToOne > > or a JoinTable for OneToMany. > > > > In your case, maybe it's better to move that association out of the > > embeddable. > > It's always a good idea to keep the model as simple as possible. > > > > Vlad > > > > On Wed, Nov 23, 2016 at 4:10 PM, Florian Lacreuse > > <florian.lacre...@smile.fr <mailto:florian.lacre...@smile.fr>> wrote: > > > > Hi, > > > > We have a problem using @AssociationOverride and @MapKeyJoinColumn > and > > we would like to have your opinion about this to know if this is > > an issue. > > > > Here is the test case : > > https://github.com/florianlacreuse/hibernate-test-case > > <https://github.com/florianlacreuse/hibernate-test-case> > > > > Short explanation about the model : an entity with an embeddable > field > > wrapping a map with an entity as key and a basic type as value. > > > > We use @AssociationOverride to rename the join table (annotation on > > embeddable field) and @MapKeyJoinColumn to rename the column > > related to > > the key map (annotation on map field). > > > > Unfortunately, it would seem that the @MapKeyJoinColumn annotation is > > ignored. @AssociationOverride may override any other annotations > > on the > > map field ? In this case how to rename the column related to the > > key map > > with the @AssociationOverride ? > > > > Is this an issue or is there any trick we don't know about? > > > > Thanks for your help. > > > > Kind regards, > > > > > > Logo <http://www.smile.fr/> > > > > 151 boulevard Stalingrad > > 69100 Villeurbanne > > www.smile.fr <http://www.smile.fr> <http://www.smile.fr/> > > *Florian LACREUSE* > > Ingénieur d'études et développement > > Pôle Développement Spécifique Java > > Open Wide - Systèmes d'Information > > Email : florian.lacre...@smile.fr > > <mailto:florian.lacre...@smile.fr> > > <mailto:florian.lacre...@smile.fr <mailto:florian.lacre...@smile.fr > >> > > > > > > _______________________________________________ > > hibernate-dev mailing list > > hibernate-dev@lists.jboss.org <mailto:hibernate-dev@lists.jboss.org> > > https://lists.jboss.org/mailman/listinfo/hibernate-dev > > <https://lists.jboss.org/mailman/listinfo/hibernate-dev> > > > > > > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev