gpt4 book ai didi

java - Hibernate:更新表查询不起作用

转载 作者:行者123 更新时间:2023-12-02 01:25:53 26 4
gpt4 key购买 nike

我有一个疑问

     public void saveReportId(BigDecimal reportId) {
entityManager.createQuery("UPDATE ReportEntity r set r.report_id = reportId WHERE s.phase = :phase")
.setParameter("reportId", reportId)
.setParameter("phase", ReportStatus.NEW.getValue())
.executeUpdate();
}

但是我没有用在参数中传递的 reportId 的值填充表,而是收到了错误:

Problem compiling - The state field cannot be resolved.

最佳答案

在命名参数查询中,您可能会错过遵循规则,即 ...condition= :paramName。因此,就您的情况而言,只需处理您的 reportId 参数即可。只需像这样更改第二个:

entityManager.createQuery("UPDATE ReportEntity r set r.report_id = :reportId WHERE s.phase = :phase")

关于java - Hibernate:更新表查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56946478/

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