I am getting these errors whenever I try to add or delete an object: org.hibernate.NonUniqueObjectException: "a different object with the same identifier value was already associated with the session."
It is inconsistent though.
It is unidirectional and here is the mapping of involved object:
Usually this happens with detached objects. You might be taking an object that isn't associated to a Session, and when you are trying to do the add or delete, there is already an object loaded into the Session that has the same ID as the detached object. When using detached objects, try "merge"ing the detached object to the Session first.
Thanks Mark. I have read and tried those things in another thread but nothing works.
Somewhere, it is saying that it is a Hibernate bug.
On my project, I have a PK of the object to delete. What I did is, get all the related objects, iterate through it, compare their PK, if their equal, get that object and delete it. It's not the best way but at least it's working.