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: detach and reattach a object from the session
PostPosted: Wed Apr 18, 2007 8:26 am 
Beginner
Beginner

Joined: Thu Jan 04, 2007 5:44 am
Posts: 26
Location: Innsbruck - Sivas(TR) - Bregenz
Hi,

I have a order-wizard in my crm software. My order objcet has some articles as childs (collection). I implement a cancel meachanism, that means I want the old state when the user cancel the orderwizard. thats means I have a copyArticles collection in order which i fill in with the new articles (copy of articles new Article()<--new objects in loop) before i start the wizard... when user click cancel i clear "Articles" collection and add the articles from the "copyArticles" collection to it.

ok before i say session.save(..) and transaction.commit() it is all okay in object view.. but when i say commit() i have the exception..

"a different object with the same identifier value was already associated with the session..."

i know i have some "Article" objects which have the same id but different object identifier...

my target is to detach the articles and reaattch the article from copyArticle.. is this possible in hibernate??

thx for your answers


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 12:03 pm 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
you may try session.saveOrUpdate or session.merge().

but there are probably other options, to get done what you want -- session.evict(), Object.clone()?

regards, martin


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.