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

我与影子孤独终老i 提交于 2019-12-01 04:08:40

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")

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!