Hibernate Docs (2.2.5.1. One-on-One) presents 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 it, it Customerhas a one-to-one relationship with Passportwhere it Customeris the owner, that is, responsible for cascading updates to Passport. mappedByThe Passportindicates that it has a one-to-one relationship with Customer, but it is not responsible for cascading updates to Customer.
Customerhas a foreign key constraint on Passport, and vice versa for Passport- Customer.
What is the meaning @JoinColumn(name="passport_fk")of Customer? How about Passportin mappedByfrom Passport? Are they table columns representing their respective foreign keys?