Community
Participate
Working Groups
Created attachment 170422 [details] project with an entity and and Embeddable Given this element collection, Dali has a validation error: 'Referenced column name must be specified when there are multiple join columns'. While this is true in the generic platform, EclipseLink supports this case and defaults the name to the id column. Easy workaround in Dali is just to specify the referencedColumnName @Entity public class Bar { @Id private int id; private int discriminator; @ElementCollection @CollectionTable(name="Foo" , joinColumns={ @JoinColumn(name="id"), @JoinColumn(name="owningEntity",referencedColumnName="discriminator") } ) private Map<String, String> foo; } Second case, EclipseLink defaults the joinColumns to id->id and id2->id2: @Entity @IdClass(BarIdClass.class public class Bar { @Id private int id; @Id private int id2; @ElementCollection @CollectionTable(name="Foo") private Map<String, String> foo; }
I have created another bug (bug 325645) for the second example.
For the first case, this problem does not only happen with a collection table involved. It also happens with other relationship mappings using the joining strategy of join table or join columns. The fix could be remove the validation message on eclipselink platform for these cases by overriding the current validation of the generic platform, e.g. we can override buildJoinTableStrategy method of GenericJavaOneToManyRelationship in the class EclipseLinkJavaOneToManyRelationship. Currently, only OneToMany mapping has the eclipselink specific relationship implemetation. We would need to add the same thing for other relationship mappings if this is the right way to fix the probem.
For the second case, it's a problem related to the use of composite primary key. Basic on the EclipseLink behavior, there are different considerations: 1. The validation error message,'Referenced column name must be specified when there are multiple join columns', is still valid when only part of a join column pair of CollectionTable joinColumns or JoinTable joinColumns is specified. 2. A new validaiton should be given when only one join column pair is specified for CollectionTable joinColumns or JoinTable joinColumns. 3. Both validaitons should not apply when using the joining strategy of JoinColums.
(In reply to comment #2) > For the first case, this problem does not only happen with a collection table > involved. It also happens with other relationship mappings using the joining > strategy of join table or join columns. > > The fix could be remove the validation message on eclipselink platform for > these cases by overriding the current validation of the generic platform, e.g. > we can override buildJoinTableStrategy method of > GenericJavaOneToManyRelationship in the class > EclipseLinkJavaOneToManyRelationship. Currently, only OneToMany mapping has the > eclipselink specific relationship implemetation. We would need to add the same > thing for other relationship mappings if this is the right way to fix the > probem. In addition, we also need to build the correct default value for the referenced column name, which is now defaulting to null in EclipseLink. For the given example, the referenceColumnName default should be 'id' since it isn't specified.
The problems discussed should also apply to the Dali validation error "Name must be specified when there are multiple join columns" which applies to the missing name value of a join column.
Validation messages regarding unspecified join column/referenced column name should not apply for joinColumns of AssociationOverride.
Moving JPA specific bugs to new JPA component in bugzilla.
this is going to be too big for 3.2 and will probably involve API changes. i'm going to call this an enhancement though it involves invalid validation. It's a "feature" in EclipseLink and not supported by the JPA spec.
Deferred to 3.4.
It's not just an EclipseLink feature. Hibernate also defaults the referenceColumnName in the same way.