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.  [ 4 posts ] 
Author Message
 Post subject: Question
PostPosted: Wed Sep 27, 2006 12:54 pm 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
i need to save an object with different values of its primary key, but if i change properties and save it i'm getting an error.

so i need to : clone the oldest one, apply my changes to newest, delete the older and save the newer, it's the right way or not ?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 1:16 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
in the future, please don't post with "Question" as your title. This gives potential helpers NO CLUE what you want and will likely gloss over it.

In order to do that you should detach the object from the session and then change the properties. When you attach the object again it will be a different identity.

I'm guessing also that GetHashCode() and Equals() might be returning identical values for your cases. Just a though.[/i]

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 5:13 pm 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
which method should i use to detach it ? session.Evict() ?

and then how can i reattach i ?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 6:03 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
session.Lock(obj) //i believe that will work.

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.