-->
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.  [ 6 posts ] 
Author Message
 Post subject: Question about saveOrUpdate and assigned id's
PostPosted: Thu Jul 07, 2005 11:16 pm 
Beginner
Beginner

Joined: Thu Jun 09, 2005 2:33 pm
Posts: 30
Can I use the saveOrUpdate method when my id generator is "assigned"? I would have to set the id property of the entity I want to persist, so how would Hibernate know to save or update based on the unsaved-value? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 12:59 am 
Beginner
Beginner

Joined: Wed Jul 06, 2005 8:18 pm
Posts: 23
I guess it can only work if you have a version field.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 1:17 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
you can also use an Interceptor ... (then you can do what ever you need to help hibernate to find out if an insert or update is required) ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 4:31 am 
Regular
Regular

Joined: Wed Feb 02, 2005 6:33 am
Posts: 70
In the mapping, can you not set the 'unsaved-value' property of the id to 'undefined'? This should force hibernate to check the database to see if the object has been persisted previously or not.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 9:14 am 
Beginner
Beginner

Joined: Thu Jun 09, 2005 2:33 pm
Posts: 30
Thanks all. I'll try setting unsaved-value to undefined and see what happens. I'll keep you posted.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 9:53 am 
In cases like this,
use <version> or <timestamp> properties in the mapping file. It works, we have been working with the same thing.


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