I saw couple of messages pointing to the same prolem that I am facing. I tried many things but my problem remains. Let me explain. I have a managed session bean that loads a list of rights. The rights are nicely presented in a table (IceFaces) and when I click on one of these rights, the details are displayed on a form. Then, I have a button named "copy" that simply copies the object and creates a new one containing the primary key. Now you would say that the key is the issue. Well, the PK for each object in my DB is consisted of 2 fields: id and languageid. So, when copying the object, the copy has always a different languageid then the original one the copy has been created from. When I try to save the copy I always get the following error message:
message: javax.persistence.PersistenceException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [org.infacom.jpa.Right#org.infacom.jpa.RightId@c9aaaa9c]
Now I tried to merge the new object (the copy) but it doesn't matter,I still get the message and there is no new record created.
Here's a piece of code:
As you can see in the "copy" code, the ID of the Right object is RightId. This one is created based on the id of the original selectedRightBean object and the languageid is the one one has selected (different).