请任何人都可以帮助我找到解决此问题的方法。
似乎在 Hibernate 中,@OneToMany
当有多个要检查的集合时,注释会出现问题。
当我尝试这样做时,它给出了这个例外Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
。
这是我的实体类:
@Entity
@Table(name = "game", catalog = "competition_manager")
public class Game implements java.io.Serializable {
private List<GamePlayerGoals> gamePlayerGoalses = new ArrayList<GamePlayerGoals>(0);
private List<GamePlayer> gamePlayers = new ArrayList<GamePlayer>(0);
@OneToMany(fetch = FetchType.EAGER, mappedBy = "game")
public List<GamePlayerGoals> getGamePlayerGoalses() {
return this.gamePlayerGoalses;
}
@OneToMany(fetch = FetchType.EAGER, mappedBy = "game")
public List<GamePlayer> getGamePlayers() {
return this.gamePlayers;
}
}
但我的问题是:在 Hibernate 中是否不可能获取超过 OnetoMany 注释的集合?提前致谢。