【发布时间】:2020-09-03 12:25:55
【问题描述】:
我有存储库方法:
@Query(value = "select t from Transaction t " +
"where t.bankAccountId in (:bankAccountIds) " +
"and t.tradeTime is not null " +
"and t.ccy is not null " +
"and t.net is not null " +
"and t.tradeTime >= :startDate and t.tradeTime <= :endDate " +
"and t.status = :status")
List<Transaction> findAllByBankAccountIdInAndTradeTimeBetween(@Param("bankAccountIds") Iterable<UUID> bankAccountIds,
@Param("status") TransactionStatus status,
@Param("startDate") LocalDateTime startDate,
@Param("endDate") LocalDateTime endDate);
但是当我尝试使用此代码时出现异常:
原因:org.postgresql.util.PSQLException: ERROR: syntax error at 或靠近“)”
如何解决?
【问题讨论】:
-
不,这不是我的问题 =(
-
你需要传入一个
List,并使用正确的语法是IN :bankAccountIds。 -
你可能是一个空的参数列表,所以你最终得到
...IN ().... -
删除括号后添加异常的完整堆栈跟踪。
标签: java jpa spring-data-jpa jpql