我有一對一的hibernate註釋映射。就像例如。hibernate如何啓動查詢?
@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
是所有者。當我對person
執行select
操作時,爲什麼hibernate會觸發兩個查詢,即從person
和passport
中選擇。 根據Hibernate文檔
the owner is responsible for the association column(s) update