0
我有這種情況。想象一下,我有A級和B級。他們之間的關係是一對多。例如,我有@OneToMany在HQL中的映射
// Class A
public class A {
private Integer id;
// some fields
@OneToMany(name = "A_ID", targetEntity = B.class)
private List<B> objectsB;
// getters and setters
}
// CLass B
public class B {
private Integer id;
// some fields
private Integer A_ID;
}
和欲寫HQL: 查詢=( 「從A aEntity選擇someField其中aEntity.objectsB.id =:參數」);
但由於映射一對多許多對象包含B(objectsB)和aEntity.objectsB.id的列表導致錯誤。誰能幫我 ?
謝謝,但我得到了MultipleBagFetchException。我的查詢是: from A aEntity join aEntity.objectsB bEntity where aEntity.someParam LIKE'%:param1%'and bEntity.id:= param2 – Chala