休眠@LazyCollection注释有什么用
2022-09-01 03:38:41
我有2个实体作为父实体和子实体作为一对多关系作为
@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)有什么用处,它什么时候会出现在图片中,比如对于子列表的哪个操作,它将是有益的?