Spring-Data FETCH JOIN with Paging is not working

前端 未结 5 1723
野性不改
野性不改 2020-11-30 05:37

I am trying to use HQL fetching my entity along with sub-entities using JOIN FETCH, this is working fine if I want all the results but it is not the case if I want a Page

5条回答
  •  有刺的猬
    2020-11-30 06:04

    Try countProjection

    @Query(value="SELECT v FROM VisitEntity v LEFT JOIN FETCH v.comments WHERE v.venue.id = :venueId and ..." ,
    countProjection = "v.id")
    public Page getVenueVisits(@Param("venueId") long venueId,...,
        Pageable pageable);
    

提交回复
热议问题