What exactly is the difference in the following two declarations
B is the owning side
@Entity
class A {
@Id int id;
@OneToOne
B b;
}
@Entity
class B {
@Id int id;
@OneToOne(mappedBy="b")
A a;
}
A is the owning side
@Entity
class A {
@Id int id;
@OneToOne(mappedBy="a")
B b;
}
@Entity
class B {
@Id int id;
@OneToOne
A a;
}
Thinking of this in "normal SQL" i think it is the same as having two tables each having the other table's foreign key. What i don't understand though is what is the effect of specifying which entity is the owning side i.e using the 'mappedBy' property. What does this actually achieve as i don't believe there is an equivalent in normal SQL.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…