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
提交
取消