I have three tables:
CREATE TABLE PostAddresses
(
contact_id INTEGER NOT NULL,
ordinal_nbr SMALLINT NOT NULL,
PRIMARY KEY (contact_id, ordinal_nbr)
);
Simply removing the @Embedded annotation from within the EmbeddedId types that reference the dependant EmbeddedIds may resolve your issue.:
@Embeddable public class FooId implements Serializable { // no annotation. private PostAddressId postAddressId; //just one field! ... } ... @MapsId(value = "postAddressId") @OneToOne @JoinColumns(value = {@JoinColumn(name = "contact_id", referencedColumnName = "contact_id"), @JoinColumn(name = "ordinal_nbr", referencedColumnName = "ordinal_nbr")}) private PostAddress postAddress = null;
(EDIT): Another issue is the use of the FooId. This class should not be used. The ID class for Foo Enitity is the PostAddressId and the OneToOne "postAddress" should simply be marked @Id and not @MapsId. Likewise BarId should not have an Embedded defined but should directly reference the PostAddressId. The Bar Mapping that references PostAddress should use MapsId.
Please file a bug against EclipseLink for the terrible exception and if removing the @Embedded and the other updates in the edit does not resolve your issue please file an EclipseLink bug for that as well.