我该如何编写这个 jpa/hibernate sql 语句(如果可能的话)
我有 2 个实体
@Entity
public class Employees
@OneToMany(cascade=CascadeType.ALL)
private List<Benefits> benefits;
========================================
@Entity
public class Benefits
private String department
我需要检索您的福利列表中包含在某些部门列表中的员工列表。
我写了以下 JPA/Hibernate sql 语句,
from Employees e where e.benefits exists ( from Benefits b where b.department in (?1) )", someListOfDepartments )
但它会引发异常。可以做这样的查询吗?