gpt4 book ai didi

java - 不能混合使用 JPA 位置参数和 native Hibernate 位置/序号参数

转载 作者:行者123 更新时间:2023-11-30 06:56:53 34 4
gpt4 key购买 nike

我正在使用 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com