【发布时间】:2012-10-07 08:40:58
【问题描述】:
我有 2 个实体作为 Parent 和 Child 作为 OneToMany 关系
@Entity
public class Parent {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private String name;
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
@IndexColumn(name = "index", base = 1)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@LazyCollection(LazyCollectionOption.EXTRA)
private List<Child> childs = new ArrayList<Child>();
// getter and setter
}
那么这里 @LazyCollection(LazyCollectionOption.EXTRA) 有什么用,什么时候会出现,比如对子列表的哪个操作,这将是有益的?
【问题讨论】:
标签: java performance hibernate orm lazy-loading