-->
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.  [ 3 posts ] 
Author Message
 Post subject: unsaved-value of an assigned id
PostPosted: Tue Feb 08, 2005 9:03 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
I think I really have problems in understanding the usage of unsaved-value.

class X ...
id .... unsaved-value = "any/none/null.."
generator = "assigned"

class Y
id ... unsaved-value = "null"
generator = "sequence"

many-to-one = x cascade= "save-update"


I really have doubts to solve the unsaved-value problem for the assigned id.

if I used the generator = " sequence" for X id, and define unsaved-value="null", it works correct since it calls save when id is null or else update if the id is not null.
but for generator = " assigned", what should I set the unsaved value to force hibernate to act as :

saveOrUpdate(y) :

saving y..
saving or updating x? // many-to-one cascade
if x is in the session(db), update x
else save it
x saved or updated
y saved

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
unsaved-value does not work properly for assigned ids. This problem is described in the Hibernate 2.1 documentation, along with the solution using Interceptor.isUnsaved().

In Hibernate3, you don't have to specify unsaved-value, and everything Just Works.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 9:22 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
if I dont specify unsaved value for the ids, it gives

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

_________________
-developer


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