EclipseLink JPA “invalid table in this context” with @OneToMany Map

后端 未结 1 745
长发绾君心
长发绾君心 2021-01-12 16:22

I\'m hoping I\'m just doing something silly here...

I\'m trying to set up JPA annotations for a Map and getting the following stack

相关标签:
1条回答
  • 2021-01-12 16:55

    This looks like EclipseLink bug 364922:

    An entity with uni-directional OneToMany property and @MapKeyColumn annotation has the correct database tables created, with the mapping table containing a "key column, but persisting an entity only populates the id columns and not the key column. The persist operation does not throw an error, but subsequent queries soon fail with the following error: Exception Description: The field [ORGANIZATION.MAILINGADDRESSES_KEY] in this expression has an invalid table in this context.

    For what it's worth, I tested your code using Hibernate/H2 and it works fine.

    UPDATE

    I just tested this with EclipseLink. If you explicitly set the table for the MapKeyColumn, the key is populated correctly. i.e.:

    @MapKeyColumn(name="PHONE_TYPE", table="EMP_PHONE")

    0 讨论(0)
提交回复
热议问题