The Hibernate Docs (2.2.5.1. One-to-one) present the following example:
@Entity
public class Customer implements Serializable {
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name="passport_fk")
public Passport getPassport() {
...
}
@Entity
public class Passport implements Serializable {
@OneToOne(mappedBy = "passport")
public Customer getOwner() {
...
}
As I understand, Customer has a one-to-one relationship with Passport, where Customer is the owner, i.e. responsible for cascading updates to Passport. The mappedBy in Passport indicates that it has a one-to-one relationship with Customer, but it is not responsible for cascading updates to Customer.
Customer has a foreign-key constraint on Passport, as well as vice-versa for Passport to Customer.
What is the meaning of the @JoinColumn(name="passport_fk") of Customer? How about passport in the mappedBy of Passport? Are they the table columns representing their respective foreign keys?