休眠、MySQL
我有以下 hql 查询:
UPDATE TaskAssessment taskAssessment
SET taskAssessment.activeFlag = false
WHERE taskAssessment IN
(
SELECT taskAssessment2
FROM TaskAssessment taskAssessment2
Where taskAssessment2.activeFlag = true
AND taskAssessment2.patient.id
AND taskAssessment2.needsLevel.careNeed = :careNeed
)
但它给了我错误:
You can't specify target table 'TASK_ASSESSMENT' for update in FROM clause
任何人都可以帮助我纠正 mysql 和 hibernate 的查询。提前致谢。
i have the following hql query:
UPDATE TaskAssessment taskAssessment
SET taskAssessment.activeFlag = false
WHERE taskAssessment IN
(
SELECT taskAssessment2
FROM TaskAssessment taskAssessment2
Where taskAssessment2.activeFlag = true
AND taskAssessment2.patient.id
AND taskAssessment2.needsLevel.careNeed = :careNeed
)
but its giving me errors:
You can't specify target table 'TASK_ASSESSMENT' for update in FROM clause
could anyone help me to correct the query for mysql and hibernate. thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要解决
您无法在 FROM 子句中指定要更新的目标表“TASK_ASSESSMENT”
,请重写查询以使用JOIN
而不是IN
(在mysql 你需要写这样的东西):To resolve
You can't specify target table 'TASK_ASSESSMENT' for update in FROM clause
, rewrite the query to useJOIN
instead ofIN
(in mysql you need to write something like this):