Hello,
I have a particular case that I don't know how to handle using annotations. I want to map the join column on the non-owner side.
For example, if I have 2 classes: Body and Head. A body is composed of one Head and a Head belongs to one Body.
As of now, I am able to map this bidirectional OneToOne relationship but by having the foreign key in the Body table. I would like to have the same functionnality as now (the Body is the Owner that manages the relationship) but with the foreign key in the Head.
My current annotations are the following:
Body.class:
Code:
private Head head;
@javax.persistence.OneToOne(cascade=CascadeType.ALL)
@javax.persistence.JoinColumn(name="HEAD_FK")
@org.hibernate.annotations.Cascade({CascadeType.DELETE_ORPHAN})
@org.hibernate.annotations.Fetch(FetchMode.SELECT)
public Head getHead() {
return this.head;
}
Head.class:
Code:
private Body body;
@OneToOne(mappedBy="head")
public Body getBody() {
return this.body;
}
Now I simply want to know how to modify this so that Body is still the Owner but so that the physical column is on the Head table.
Thanks for your help,
Francois