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