JPA2 Criteria-API: select… in (select from where)
I have the following database model: A aId AB aId bId B bId status In a Spring data Specification, I want to return the instances of A when B.status is 'X'. The JPQL code is the following: select a from A a where a in (select ab.id.a from AB ab where ab.id.b.status= :status) These are the model classes: @Entity public class A { private Long aId; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "id.a") private Set<AB> ab; } @Entity public class B { private Long bId; private String Status; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "id.b")