基本上我有3个表:COUNTRY,STATE和CITY。
Country.java: 中的
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "COUNTRY_ID")
private List<State> state = new Vector<State>();
State.java 中的
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "STATE_ID")
private List<City> city = new Vector<City>();
JPA查询如下:
caEntityManager.createQuery("SELECT C FROM COUNTRY C
JOIN fetch C.STATE S JOIN fetch S.CITY").getResultList();
当我尝试执行查询时,我得到:
org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
我确信我的查询错了,我是新手,请指定我正确的方向。我
谢谢!
答案 0 :(得分:1)