How to use multiple JOIN FETCH in one JPQL query

前端 未结 3 1981
独厮守ぢ
独厮守ぢ 2020-12-13 13:12

I have below entities:

public class Category {
   private Integer id;

   @OneToMany(mappedBy = "parent")
          


        
3条回答
  •  自闭症患者
    2020-12-13 13:35

    Here is a working example of complex join and multiple consition:

        String query_findByProductDepartmentHospital = "select location from ProductInstallLocation location "
                + " join location.product prod " + " join location.department dep "
                + " join location.department.hospital hos " + " where  prod.name = :product "
                + " and dep.name.name = :department " + " and hos.name = :hospital ";
    
        @Query(query_findByProductDepartmentHospital)
        ProductInstallLocation findByProductDepartmentHospital(@Param("product") String productName,@Param("department") String departName, @Param("hospital") String hospitalName);
    

提交回复
热议问题