gpt4 book ai didi

java - HIBERNATE 在更新对象时抛出错误 :"a different object with the same identifier value was already associated with the session "

转载 作者:太空宇宙 更新时间:2023-11-04 15:21:45 24 4
gpt4 key购买 nike

更新对象时无法更新并抛出上述错误

PublishedAssessmentData associatepublishobj = (PublishedAssessmentData) associatePublishedobjectdata.get(i);                  
PublishedAssessmentData existing_publishobj = service.transferupdatedpublishedassessments(associatepublishobj,sbipublishobj);
openSession.saveOrUpdate(existing_publishobj);

最佳答案

唯一的原因可能是,您从 Hibernate 获取了对象,然后再次尝试 saveOrUpdate。您之前在 Session 中保存过对象,并且您正在尝试再次保存它。

在该对象关联或获取的 session 上调用 commit。

关于java - HIBERNATE 在更新对象时抛出错误 :"a different object with the same identifier value was already associated with the session ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20322859/

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