分页不适用于Spring Data Jpa中带有命名查询的join 2表

mv1qrgav  于 11个月前  发布在  Spring
关注(0)|答案(1)|浏览(109)

我们尝试使用连接对命名查询进行分页,但失败了。

select laptop0_.id as id1_1_, laptop0_.brand_id as brand_id4_1_, laptop0_.name as name2_1_, laptop0_.price as price3_1_ from tbl_laptops laptop0_ left outer join tbl_brand brand1_ on laptop0_.brand_id=brand1_.id where brand1_.brand =:?

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

字符串
2个表之间没有fourign键,我仍然希望在Spring Data Jpa中使用SQL joins进行分页。

mwyxok5s

mwyxok5s1#

我修正了2个查询的分页问题。一个是SQL查询,按字段名,排序方向,偏移量和限制排序。
第二个查询是获取总页数的总记录。

相关问题