> I have to tables (FIELD and FIELDACCESS) in our DB that share the same
> primary key. There is a one-to-one relationship from FIELD to
[quoted text clipped - 37 lines]
> get the error "Join column 'fieldAccess_fieldid' cannot be resolved".
> However, it appears to me that "fieldid" does exist in FieldAccess.
Try this:
@PrimaryKeyJoinColumns( {
@PrimaryKeyJoinColumn( name = "fieldid",
referencedColumnName = "fieldid" )
} )
The default naming of the FK in a 1:1 relation is <target entity
name>_<PK column name of target> -> fieldAccess_fieldid.
If you want something else you'll have to define it like above.
Dave - 09 Nov 2007 18:58 GMT
Well, that kinda works. It gets rid of the error but when I try to
persist
the objects, the FieldAccess entity is created before the Field
entity,
which causes an integrity constraint rule to fire because the Field
entity is the parent it has to be created first. The FieldAccess
entity
cannot exist without the Field.
I swapping the annotations around but now I get the following error
when
I try to run my test:
org.hibernate.AnnotationException: Unknown mappedBy in:
ca.ums.core.entities.Field.fieldAccess, referenced property unknown:
ca.ums.core.entities.FieldAccess.field
Any ideas?
> > I have to tables (FIELD and FIELDACCESS) in our DB that share the same
> > primary key. There is a one-to-one relationship from FIELD to
[quoted text clipped - 48 lines]
> name>_<PK column name of target> -> fieldAccess_fieldid.
> If you want something else you'll have to define it like above.