@OneToMany(mappedBy="post",
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
fetch=FetchType.EAGER
)
public List<Tag> getTags() {
return tags;
}
在上述代码运行就会引起最终错误:cannot simultaneously fetch multiple bags
fetch=FetchType.EAGER
在查找的错误原因中有可能是我运用了List。
为何我用List而不用Set呢,因为我其中需要对tags进行操作,list操作起来比较方便
所以在查找的解决方法,我把我的代码修改成如下:
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy="post",
cascade = {CascadeType.PERSIST, CascadeType.MERGE}
)
public List<Tag> getTags() {
return tags;
}