首页 > 解决方案 > 分页和天真的查询 + eclipse 链接

问题描述

我正在尝试在 Eclipse 链接 + JPA for PostgreSQL 中编写本机查询和分页

但我遇到了例外:

这是我尝试过的代码:

@Query(nativeQuery = true, value= "select a.* from rqst a LEFT OUTER JOIN table_b b ON a.id= b.id where a.code='abc' ORDER BY /*#pagable*/") 

@Query(nativeQuery = true, value= "select a.* from rqst a LEFT OUTER JOIN table_b b ON a.id= b.id where a.code='abc' ORDER BY ?#{#pageable}") 

我跟着这个链接但没有运气:

带有分页的 Spring Data 和 Native Query

任何帮助表示赞赏

当我使用第二个查询时,我得到了这个异常:

Can't infer the SQL type to use for an instance of org.springframework.data.domain.PageRequest. Use setObject() with an explicit Types value to specify the type to use.
    at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:1039) ~[postgresql-9.4.1208.jar:9.4.1208]

标签: javapostgresqlpaginationspring-data-jpanativequery

解决方案


推荐阅读