Spring-Data FETCH JOIN with Paging is not working

前端 未结 5 1746
野性不改
野性不改 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:07

    Alternatively in newest versions of Spring (supporting JPA 2.1 specification) you can use entity graph like this:

    @EntityGraph(attributePaths = "roles")
    @Query("FROM User user")
    Page findAllWithRoles(Pageable pageable);
    

    Of course named entity graphs work as well.

提交回复
热议问题