Hi,
I have 2 Entities Prj & Emp with a many-many mapping. Below is the structure for the same
Prj- PrjPid
- PrjName
- PrjPhone
- List<Emp> employees
Emp- EmpPid
- EmpName
- EmpPhone
- EmpPhone
- List<Prj> projects
I wish to retrieve a list of Project names given an Employee Name.
For the same I have written
Code:
List<String> s1 = JPA.em()
.createQuery("SELECT project.PrjName FROM EmpOTO WHERE EmpName = ?")
.setParameter(1, "Employee1")
.getResultList();
However I get an error
Code:
[IllegalArgumentException: org.hibernate.QueryException: illegal attempt to dereference collection [{synthetic-alias}{non-qualified-property-ref}projects] with element property reference [PrjName] [SELECT projects.PrjName FROM ormmapping.manytomany.models.EmpMTM WHERE EmpName = ?]]
Please could somebody assist.
-S