【发布时间】:2019-03-22 13:22:14
【问题描述】:
我正在尝试使用以下命令从 jpa 存储库中查询 postgres 数据库:
@Query(value =
"SELECT " +
"string_agg(distinct customer_po, ', ') as customer_po, " +
"customer_part, " +
"description, " +
"bunzl_loc, " +
"sum(dayspastexpected) as longestGrouping, " +
"string_agg(distinct priority, ', '), " +
"sum(open_qty) as totalBoQty, " +
"sum(current_oh) as sunAvail, " +
"next_receipt " +
"FROM " +
"sap_data.openorders_report " +
"WHERE " +
"run_date between :from and :to " +
"AND " +
"backorderorfuture = 'Future' " +
"GROUP BY " +
"customer_part, " +
"bunzl_loc, " +
"description, " +
"next_receipt " +
"ORDER BY " +
"customer_part desc, " +
"bunzl_loc desc /*#pageable*/",
nativeQuery = true)
Page<SapOpenOrder> getBackOrderReport(@Param("from") Date from, @Param("to") Date to, Pageable pageable);
但我收到此错误:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "WHERE"
我可以在 dbeaver 中运行此查询并获得正确的结果。如何使用 spring jpa 运行此查询?
【问题讨论】:
标签: spring-data-jpa nativequery