0
votes

I'm currently trying to implement a ManyToMany Relationship with Data in the JoinTable. I'm following this approach with the Eclipselink JPA Framework. But I'm getting the following exception:

org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 23 more Caused by: Exception [EclipseLink-7298] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.ValidationException Exception Description: The mapping [group] from the embedded ID class [class de.kapieren.mbm.server.model.UserGroupPK] is an invalid mapping for this class. An embeddable class that is used with an embedded ID specification (attribute [pk] from the source [class de.kapieren.mbm.server.model.GroupMembership]) can only contain basic mappings. Either remove the non basic mapping or change the embedded ID specification on the source to be embedded

Does anybody know whats the meaning of basic mappings in relationship to embeddedId? What could be wrong here?

1

1 Answers

3
votes

EclipseLink is complaining about the use of non Basic mappings (for example a ManyToOne) in an Embeddable class used as a primary key (i.e. annotated with EmbeddedId).

And according to the JPA 2.0 specification, this is indeed not supported:

11.1.15 EmbeddedId Annotation

The EmbeddedId annotation is applied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. The embeddable class must be annotated as Embeddable. Relationship mappings defined within an embedded id class are not supported.

If I rephrase, the EmbeddedId's Embeddable class must define each id attribute for the entity using Basic mappings in standard JPA.

References

  • JPA 2.0 Specification
    • Section 11.1.15 "EmbeddedId Annotation"