How to access child class entity fields in native query?

378 Views Asked by At

i have two entity classes both are in relation.am skipping annoatation part and remaining fields in the below code.

class Employee{
  Department department;
}
class Department{
 String departmentName;
}

when i try to access departmentName in native sql query am getting error unknown column. query is
select * from employee where employee.department.departmentname=?; how can i access child class entities? some one please help me.

1

There are 1 best solutions below

2
Amit Mendapara On

Native query as the name suggest is pure SQL dialect of the underlying db server and has nothing to do with HQL/JPQL. You have to use JOIN with actual tables and column names.