I'm having difficulty determining the right way to write a Predicate with QueryDSL and Spring Data JPA.
Take the following Data model:
I want the Predicate to evaluate to true for companies that have employees in the Research division, so I create the following class:Code:public class Company { @OneToMany private Set<Employee> emps; } public class Employee { @ManyToOne private Division division; } public class Division { private String name; }
This code would be called using:Code:public class CompanyPredicates { public static Predicate hasResearchEmployees { return QCompany.company.emps.???.division.name.eq("Research"); }
Can somebody help me fill in the question marks in the hasResearchEmployees method?Code:List<Company> companies = CompanyRepository.findAll(hasResearchEmployees());


Reply With Quote