Jpa两表分页
@Query(
value = “select c.* from course c,user_class u where u.user_id=c.course_id and u.is_online=0 and c.mark_time between :starttime and :endtime /* #pageable */”,
countQuery = “select count(1) from user_class u, course c where u.user_id=c.course_id and u.is_online=0 and c.mark_time between :starttime and :endtime”,
nativeQuery = true)
Page findCourseAndUserClassByMarkTime(@Param(“starttime”) long starttime, @Param(“endtime”)long endtime, Pageable pageable);
其中 nativeQuery = true 为执行原生sql之意,
/ #pageable / 注释里面的意思就是让jpa 识别 pageable 不能省略