我有这种情况。想象一下,我有 A 类和 B 类。它们之间的关系是一对多的。例如我有
// 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: Query = ("select someField from A aEntity where aEntity.objectsB.id = :parameter ");
但由于映射一对多 A 对象包含 B 列表(objectsB)和 aEntity.objectsB.id 导致错误。谁能帮我 ?