Possible Duplicate:
Hibernate: different object with the same identifier value was already associated with the session
I have a problem with Hibernate:
I have the following class: Person
I'm loading a specific Person.class "A" from the db on the server-side. Then I present this object to the client via a JSP page.
The client manipulates "A" to "B" and then sends it back via the form. I load the Person.class "B" object on the server-side into a new variable and then try to store it.
But as the whole application is session based I cannot simply call:
HibernateTemplate.saveOrUpdate("B");
Instead I have to merge "B" with "A" before saving it.
But when I call
HibernateTemplate.merge("B");
the "B" object still gets all the properties of "A" which i would not like to store anymore. I'd like that "B" replaces the "A" object completely without getting some of the "A"-properties by merging them.
So my question is:
Is there in Hibernate any "overwrite" or "replace" function which can overwrite all the objects in a session which have the same identifier with the properties of one specific object?
(In the example the returned object "B" from the form)
It should also prevent Hibernate from complaining about:
Exception in thread "main" org.hibernate.NonUniqueObjectException: a
different object with the same identifier value was already associated
with the session: