Hibernate在SessionFactory创建期间抛出此异常:org.hibernate.loader.MultipleBagFetchException:不能同时获取多个包这是我的测试用例:Parent.java@Entitypublic Parent {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@OneToMany(mappedBy="parent", fetch=FetchType.EAGER)
// @IndexColumn(name="INDEX_COL") if I had this the problem solve but I retrieve more children than I have, one child is null.
private List<Child> children;}Child.java@Entitypublic Child {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
@ManyToOne
private Parent parent;}这个问题怎么样?我能做什么?
3 回答
慕田峪7331174
TA贡献1828条经验 获得超13个赞
@LazyCollection(LazyCollectionOption.FALSE)
fetchType
@*ToMany
Set<Child>
List<Child>
List
Set
aluckdog
TA贡献1847条经验 获得超7个赞
XXXToMany(mappedBy="parent", fetch=FetchType.EAGER)
@Fetch(value = FetchMode.SUBSELECT)
添加回答
举报
0/150
提交
取消