Hello all,
I would like to accomplish a bidirectional mapping to a class used in multiple fields.
Example:
"The owner" (see
http://docs.jboss.org/hibernate/stable/ ... e/#d0e1039):
Code:
public class House {
@OneToOne (fetch = FetchType.EAGER)
@Cascade ({CascadeType.PERSIST,CascadeType.MERGE,CascadeType.SAVE_UPDATE})
@ForeignKey(name="FK_House_Gardener", inverseName="FK_Gardener_House")
private HouseEmployee gardener;
@OneToOne (fetch = FetchType.EAGER)
@Cascade ({CascadeType.PERSIST,CascadeType.MERGE,CascadeType.SAVE_UPDATE})
@ForeignKey(name="FK_House_Caretaker", inverseName="FK_Caretaker_House")
private HouseEmployee caretaker;
}
"The not responsible class" (see
http://docs.jboss.org/hibernate/stable/ ... e/#d0e1039):
Code:
public class HouseEmployee {
// Will work, but only if this Employee is the gardener
//@OneToOne(fetch = FetchType.EAGER, mappedBy="gardener")
// Will work, but only if this Employee is the caretaker
//@OneToOne(fetch = FetchType.EAGER, mappedBy="caretaker")
@OneToOne(fetch = FetchType.EAGER, mappedBy="###what-to-enter?###")
@Cascade ({CascadeType.PERSIST,CascadeType.MERGE,CascadeType.SAVE_UPDATE})
private House house;
}
How can I accomplish that the "house"-property in HouseEmployee is filled in both cases?
Thank you very much for any hint!
Best regards
Stephan