我有一对一的休眠注释映射。喜欢例如。
@Entity
@Table(name="person")
class Person{
@OneToOne( mappedBy = "person", cascade = CascadeType.ALL)
private Passport passport;
......
}
@Entity
@Table(name="passport")
class Passport{
@OneToOne
@JoinColumn(name = "statusid")
private Person person;
......
.....
}
这里Person
是拥有者,Passport
也是所有者。当我执行select
操作时,person
为什么休眠会触发两个查询,即 select fromperson
和passport
. 根据休眠文档
the owner is responsible for the association column(s) update