我得到一个异常,描述“此表达式中的字段[EMPLOYEE.ID]在此上下文中有一个无效的表。”,当尝试执行此查询时,应该选择给定员工的所有活动
final Query query = getEm()
.createQuery(
"SELECT a from Activity a WHERE a IN (SELECT ae FROM a.employees ae) "
+ "AND ?1 IN (SELECT ae FROM a.employees ae)");
query.setParameter(1, employee);
return (List<Activity>) query.getResultList();
这是我的类Activity中的地图注释:
@OneToMany
@JoinTable(name = "ACTIVITY_EMPLOYEES", joinColumns = @JoinColumn(name = "ACTIVITY_ID"), inverseJoinColumns = @JoinColumn(name = "EMPLOYEETIMEPERIODS_ID"))
@MapKeyJoinColumn(name = "EMPLOYEE_ID", table = "ACTIVITY_EMPLOYEES")
private Map<Employee, EmployeeTimePeriods> employees = new HashMap<>();
我有什么建议可以解决这个问题吗?是否有其他方式来获得特定员工的所有活动?
提前致谢。