Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Regression 2.1.1 -> 2.2.0? @JoinColumn referencedColumnId

Hello Laird,

 

When you say that the JoinTable's inverse columns needlessly specifies a referencedColumnName and show it commented out, are you saying this is not involved in the error, or that the error occurs when this field is included.  I can see no problem with the mapping if the join table is defined as;
@JoinTable(name = "Person_EthnicityType", joinColumns = { @JoinColumn(name = "personId", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "ethnicity_type_id") })

If the referencedColumnName = "id" being included in inverseJoinColumns results in this error, what is the ID field on the EthnicityType entity? 

If its not involved, does the mapping work if referencedColumnName = "id" is removed from the @JoinColum? 

 

I could be wrong, but believe this issue is arising from validation added for bug 317286, and suspect that the EthnicityType's primary key field is "ID" resulting in a case mismatch.  Please include the error stack trace though if this is not the case. 

 

Best Regards,
Chris

 


----- Original Message -----
From: ljnelson@xxxxxxxxx
To: eclipselink-users@xxxxxxxxxxx
Sent: Wednesday, November 10, 2010 4:20:17 PM GMT -05:00 US/Canada Eastern
Subject: [eclipselink-users] Regression 2.1.1 -> 2.2.0? @JoinColumn referencedColumnId

There might be a regression here.

My colleague has an entity (Person) that inherits from a mapped superclass.  The mapped superclass defines an @Id column:

  @Id
  @Column(name = "id")
  private int id;

Then the Person entity defines a unidirectional @OneToMany with a @JoinTable to another entity called EthnicityType.  One of the @JoinTable's inverse columns needlessly specifies a referencedColumnId = "id":

    @OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinTable(name = "Person_EthnicityType", joinColumns = { @JoinColumn(name = "personId", referencedColumnName = "id") }, inverseJoinColumn! s = { @JoinColumn(name = "ethnicity_type_id"/*,referencedColumnName = "id"*/) })
    private Set<EthnicityType> ethnicityType=new HashSet<EthnicityType>();

EclipseLink 2.1.1 happily lets this fly.  EclipseLink 2.2.0 as packaged in Glassfish 3.1-SNAPSHOT barks with this error:

Exception Description: The reference column name [id] mapped on the element [field ethnicityType] does not correspond to a valid field on the mapping reference.

Is there an obvious mapping problem here?

Thanks,
Laird


Back to the top