Community
Participate
Working Groups
I have tested this with the 2.2.0v20100819-r8063 build and in the 2.2.0.v20100908-r8149 build. This model works fine in the 8/19 build, but in the 9/08 build EclipseLink gets the following exception while processing the JPA metadata. This should be a valid model. From looking at the code history it looks related to Guy's changes on 9/3 for bug 317286. Also, the exception message is missing the word "not" @Entity public class Bar { @Id private int id; private int discriminator; @ElementCollection @CollectionTable(name="BLAH", joinColumns={ @JoinColumn(name="id"), @JoinColumn(name="owningEntity", referencedColumnName="discriminator") } ) private Map<String, String> foo; } Exception Description: The reference column name [discriminator] mapped on the element [field foo] does correspond to a valid field on the mapping reference. at org.eclipse.persistence.exceptions.ValidationException.invalidReferenceColumnName(ValidationException.java:1790) at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:419) at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ElementCollectionAccessor.processCollectionTable(ElementCollectionAccessor.java:745)
For this model to work correctly right now, you need to set the case insensitivity flag, that is, the property: eclipselink.jpa.uppercase-column-names to true. That property currently defaults to false, meaning for the attribute private int discriminator; it defaults the field name to 'DISCRIMINATOR' whereas the referenced column name refers to 'discriminator' and these are therefore treated as two different fields. Once bug 294267 is fixed, we will be case insensitive by default and this model will work as is. *** This bug has been marked as a duplicate of bug 294267 ***
Also, I did add the 'not' to the exception string, thanks for catching that.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink