I investigating ways of create one to one relation between two entities in hibernate.
All examples which I have read use cross referernces:
https://stackoverflow.com/a/21762450/2674303
and
http://www.mkyong.com/hibernate/hibernate-one-to-one-relationship-example-annotation/
At this example:
public class User {
@OneToOne(mappedBy = "user")
private Status status;
// ...
}
public class Status {
@OneToOne
@JoinColumn(name = "frn_user_id")
private User user;
// ...
}
User
has reference to Status
and Status
has reference to User
In my opinion Status
shouldn't know anything about User
. I want that only User
have reference to Status
.
Is it possible or I don't understand something?