Skip to content Skip to sidebar Skip to footer

Not Able To Fetch Child Entities Using Inner Join In Spring Data Jpa

Hi I am trying to fetch a parent class Department where I have a clause for employee as well. In the Employee table I have an indicator is_active. I need to find a department which

Solution 1:

You can try fetch join to eagerly fetch child entities. Query should look next:

  @Query("select t1 from Department t1 inner join fetch t1.employee t2 where t1.deptHead = :deptHead and t1.departmentId = :deptId and t2.isActive != 'N')

Post a Comment for "Not Able To Fetch Child Entities Using Inner Join In Spring Data Jpa"