-
1. Re: Can not seem to name foreign keys in relationships
lafr Sep 1, 2007 3:31 PM (in response to barondodd)did you try to specify the name with referencedColumnName:
@JoinColumn(name="catalogueFk",referencedColumnName="catalogue") -
2. Re: Can not seem to name foreign keys in relationships
barondodd Sep 3, 2007 5:13 AM (in response to barondodd)Thanks for the suggestion, unfortunately it did not solve the issue:
org.hibernate.MappingException: Unable to find column with logical name: catalogue in org.hibernate.mapping.Table(Catalogue) and its related supertables and secondary tables
From what we have learnt we know the following:
a) The mappedBy attribute must reference the logical name of the foreign property (the name of the attribute / getter)
b) The name attribute of the JoinColumn appears to be the physical column name for the foreign key
c) It only works if these two values are the same, but not if that value is anything other than the name of the getter/setter property.
Which brings us back to square 1! How do we specify a different physical name for the foreign key?! -
3. Re: Can not seem to name foreign keys in relationships
barondodd Sep 3, 2007 9:03 AM (in response to barondodd)Fixed it, it was the precence of the following that was causing the problem:
@UniqueConstraint(columnNames={"name","catalogue"}
Should have been
@UniqueConstraint(columnNames={"name","catalogueFK"}