I am having problems with EJB3 bidirectional relationships. We are upgrading an 
EJB2 system to EJB3 and the names of our foreign key columns are causing us a 
headache.

Table ArchiveSet has a foreign key into table Catalogue via the column 
CATALOGUEFK
So we need a many-to-1 relationship.

I create that side of the relationship and specify the name of the foreign 
key....

@Entity
  | public class ArchiveSet ...
  | 
  |     @ManyToOne
  |     @JoinColumn(name="catalogueFK")
  |     public Catalogue getCatalogue() {
  |         return catalogue;
  |     }

I then complete the relationship and map to the catalogue property of  the 
ArchiveSet entity...
@Entity
  | public class Catalogue ...
  | 
  |     @OneToMany(mappedBy="catalogue")
  |     public Collection<ArchiveSet> getArchiveSets() {
  |         return archiveSets;
  |     }

The following error occurs:

org.hibernate.MappingException: Unable to find column with logical name 
catalogue in table ArchiveSet

We have tried everything and it will only stop moaning if both the JoinColumn 
name and the mappedBy name are "catalogue". The @Column annotation is not 
allowed in conjunction with the @ManyToOne annotation (don't know where this is 
documented...), so how on earth do I specify a different name for the foreign 
key?!! This could be a blocker to using EJB3.


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080092#4080092

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080092
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to