-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Difference between saveOrUpdate and saveOrUpdateCopy
PostPosted: Thu Sep 02, 2004 4:54 pm 
Newbie

Joined: Mon Aug 09, 2004 10:53 am
Posts: 19
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?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 6:14 am 
Newbie

Joined: Mon Aug 09, 2004 10:53 am
Posts: 19
Can anyone explain the difference between saveOrUpdate and saveOrUpdateCopy in the context of my question?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.