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
The easiest way is to use the countQuery attribute of the the @Query annotation to provide a custom query to be used.
@Query(value = "SELECT v FROM VisitEntity v LEFT JOIN FETCH v.comments …",
countQuery = "select count(v) from VisitEntity v where …")
List getVenueVisits(@Param("venueId") long venueId, …);