hibernate lazy 懒加载

The short answer is: Hibernate does NOT support lazy one-to-one relationships

the long answer is: workaround 1) declare the releationship to be one-to-one on one side (child), and one-to-many on the other side (parent) Thus a parent.getchild() returns a set, yet it will be able to use lazy loading.

2) you can try to have the parent and the children to share the primary key, but this would require ou to alter the schema

3) you can try to configure a view in your database reflecting this one-to-one relationship/.

hibernate OneToOne child side oneToMany parent side 不支持懒加载
设置 OneToOne parent side child side 共享主键 但要修改表结构。

你可能感兴趣的:(Hibernate,lazy)