请帮助我获取以下给定实体类的以下sql的条件构建器版本:
SQL:
select u.userid from employee e inner join user u on e.userid=u.userid
inner join employee_project ep on ep.empId=e.empId
inner join ep.projectId=p.projectId where p.projectId in (?,?...);
此外,它也应该可以用作子查询。
@Entity
@Table(name="Employee")
public class Employee {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
private Long id;
@OneToOne(optional=false, cascade=CascadeType.ALL, orphanRemoval=true)
@JoinColumn(name="userId")
private User user;
@ManyToMany
@JoinTable(
name="Employee_Project",
joinColumns={ @JoinColumn(name="empId", referencedColumnName="empId") },
inverseJoinColumns={ @JoinColumn(name="prjId", referencedColumnName="prjId") }
)
private List<Project> project;
}