我正在尝试为其 CReference 实体集合中的所有子项都满足条件的实体 A 选择条目。我目前的查询只需要至少一个成员满足条件。
当前查询
此查询当前选择类型 A 的所有对象,其中至少一个项目在其 c_references 类中
SELECT a FROM A a INNER JOIN FETCH a.c_references c_refs INNER JOIN FETCH c_refs.c_reference c_ref WHERE (c_ref.flag_one=TRUE AND c_ref.flag_two=TRUE)
课程
A级
@Entity
public class A{
@Id
private UUID a_uuid;
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "owning_a_uuid")
private List<CReference> c_references;
}
类 C 参考
@Entity
// This class keeps references to all of the A objects that have referenced a C object
public class CReference{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long c_reference_id;
@OneToOne
private A a_referencing_c;
@OneToOne
private C c_reference;
}
C类
@Entity
@Cacheable
public class C{
@Id
private UUID c_uuid;
private Boolean flag_one = false;
private Boolean flag_two = false;
}