Possible Duplicate:
Hibernate: different object with the same identifier value was already associated with the session
I have got almost the same problem like that user.
In my situation I load one entity from db, I convert this entity into a DataTransferObject, then I want to edit one attribute, after that I convert it back into an entityObject, then I update that entity and hibernate throws following error:
Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
Apparently, the problem is that the object I retrieve from db has the same id as the one I want to update (like it should be) BUT those are not the same objects!
How to manage that?
Thank you for help…
Your problem is that the object you previously loaded still exists in your hibernate session. I see two ways to cope with that.
1.) tell the hibernate session to merge your modified object with the one in the session
2.) kick the old object out of the session before writing the updated object to the session. session.clear() might work.