gpt4 book ai didi

java - 执行domain.save()时Grails触发查找和保存查询

转载 作者:太空宇宙 更新时间:2023-11-04 11:10:54 25 4
gpt4 key购买 nike

我在 Grails2x 中有一段带有 sql 数据库的代码。我有一个映射到域的表。它与 grails2x 一起工作正常,但当我将其更新到 grails 3.2.9 时,当我执行domain.save() 时,它会在 hibernate 中触发查找查询,然后更新查询,最后失败。

下面我附上了错误日志:

org.springframework.orm.hibernate5.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

对于那些数据类型为 varchar 的表,我还想添加一件事,domain.save() 工作正常,但列 nvarchar 类型的表给出上述错误。有人可以向我解释一下原因及其预期的解决方案吗?

最佳答案

在定义 id 的映射时,我在不同的映射主键中缺少生成器:“已分配”

关于java - 执行domain.save()时Grails触发查找和保存查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46009239/

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