【发布时间】:2020-09-29 22:51:47
【问题描述】:
我想使用基于 Spring MVC 的 Hibernate 项目执行 CRUD 操作,到目前为止我已经成功执行了添加、删除操作。但是在更新数据时,我收到错误显示如下。我尝试将我的主键添加到会话中,并沿着要从 jsp 页面更新的数据检索它。但是我在 hibernatetemplate.update(emp) 行中遇到了错误。其中 emp 是要使用与数据库中相同的主键更新的对象。我正在使用 ECLIPSE IDE 和 Tomcat v9 服务器。
Servlet.service() for servlet [dispatcher] in context with path [/Demo] threw exception [Request processing failed; nested exception is org.springframework.dao.DuplicateKeyException: A different object with the same identifier value was already associated with the session : [com.wipro.bean.Employee#254]; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [com.wipro.bean.Employee#254]] with root cause
org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [com.wipro.bean.Employee#254]
【问题讨论】:
标签: spring hibernate session orm