See Thread at: http://www.techienuggets.com/Detail?tx=11691 Posted on behalf of
a User
>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"}
Hi, where did you add this unique contraint ? on the table or the column ? I
guess column.. and in which class ??
In Response To:
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.
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user