Hibernate version: 2.1
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
Debug level Hibernate log excerpt:
What is the difference between the 2?
Here is the scenario :
In this case I load up an existing store object from the db into the Hibernate session, (call it oldStore) create a new store (call it newStore) in the session that is meant to replace it and then proceed to update the id fields of new Store and it's members i.e. storeId, all the productIds, categoryIds etc. I then tried to call saveOrUpdate on newStore.
However this results in the following error:
a different object with the same identifier value was already associated with the session: 1, of class: com.cnetnetworks.api.psp.catalog.Store; nested exception is net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1, of class: com.cnetnetworks.api.psp.catalog.Store org.springframework.orm.hibernate.HibernateSystemException: a different object with the same identifier value was already associated with the session: 1, of class: com.cnetnetworks.api.psp.catalog.Store; nested exception is net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1, of class: com.cnetnetworks.api.psp.catalog.Store net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1, of class: com.cnetnetworks.api.psp.catalog.Store
However when I used saveOrUpdateCopy it overwrote the old instance as I had intended. Why does it succeed in updating the existing instance with saveOrUpdateCopy but produces a NonUniqueObjectException with saveOrUpdate?
|