我正在使用 Hibernate/JPA 执行 native PostGIS 查询。这些查询的问题在于它们需要不是经典 X = 'value' 形式的参数。
我的查询是:-
@Modifying
@Query(value="UPDATE memo SET readMemo = true and updatedBy_id = ?1 and updatedBy = ?1 and updatedOn = ?2 where assignToUser_id = 1? and readMemo = false and deleted = false ",nativeQuery = true)
void readAllMenoByCurrentUser(Long id, Date updateTime);
错误:-
org.springframework.dao.InvalidDataAccessApiUsageException: Cannot mix JPA positional parameters and native Hibernate positional/ordinal parameters; nested exception is java.lang.IllegalArgumentException: Cannot mix JPA positional parameters and native Hibernate positional/ordinal parameters
有谁知道在这种情况下如何解决?
最佳答案
您的查询中有 "1?"
。这将意味着它试图将其解释为“?” (SQL 参数)而不是位置参数。将其更改为 "?1"
关于java - 不能混合使用 JPA 位置参数和 native Hibernate 位置/序号参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33984629/