我们尝试使用连接对命名查询进行分页,但失败了。
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进行分页。
1条答案
按热度按时间mwyxok5s1#
我修正了2个查询的分页问题。一个是SQL查询,按字段名,排序方向,偏移量和限制排序。
第二个查询是获取总页数的总记录。