1

I get an exception with the description "The field [EMPLOYEE.ID] in this expression has an invalid table in this context.", when trying to execute this query, which should select all acivities of the given employee

        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();

This is the map annotation in my class 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<>();

Any suggestions how I could solve this? Is there maybe another way, to get all activities of an given employee?

Thanks in advance.

triplec0re
  • 31
  • 5

0 Answers0