我在 stackoverflow 中针对 native 查询中的分页进行了此操作,返回记录时没有错误。它给出所有记录,而不是在可分页 ex 中获取参数值:iam 将这些 pageSize(5 或 4)和 pageNo(0)传递给可分页参数。
@Query(value = "select * from job_post where comp_addr_ref_id not in"
+ "(select mapping_id from company_address where ref_company_id in"
+ "(select mapping_id from company where mapping_id in"
+ "(select comp_ref_id from comp_visibility where is_comp_visible=0 and login_ref_id=:mappingId)))"
+ " order by created_date desc \n#pageable\n", nativeQuery = true)
public List<JobPost> findUserBlockedCompanies(String mappingId, Pageable pageable);
最佳答案
如果您使用的是 Spring Boot 2.0 或更高版本,请尝试删除 \n#pageable\n
部分。
如果您使用 PostgreSql 和 MySql,请将值 \n#pageable\n
更改为
?#{#pageable}
如果仍然不起作用,您可以在 application.properties
中使用 spring.jpa.show-sql=true
启用 SQL 语句日志记录
关于java - native 查询返回 Spring Boot 中 #pageable 的所有记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59208947/