我有两个对象:User和Resume. 简历有一个User user字段。在我的代码中,我首先获取一个user对象并对其进行一些更改。如果Resume.findByUser(user)存在,我会得到简历并在那里进行一些更改。
如果我打电话user.save(),resume.save()我得到一个异常,说会话中有另一个对同一个对象的引用,所以我开始使用merge().
当我打电话时user.merge(),数据被保存,但是当我打电话时,resume.merge()我得到了这个异常:
org.springframework.dao.DuplicateKeyException: a different object with the same identifier value was already associated with the session: [com.wizard.security.User#36]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.wizard.security.User#36]
我不知道该怎么办。看起来问题出在resume.user与user.
对于这个问题,我将不胜感激,谢谢。