-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate update example
PostPosted: Tue Aug 03, 2004 9:51 pm 
Newbie

Joined: Wed Jan 28, 2004 5:21 pm
Posts: 18
Location: Maracaibo, VZLA
Hi, I have an one-to-many parent/child associations, and I want to update those classes changing some values of parents and some values of childs, also I'd like to add two new childrens, my questions is: How can I do that ?? I'm using assigned ID generations and I'm not using unsaved-value parameter in the mapping file...
Does anyone can tell me where can I find a source code example of that ???

I hope I was clear and somebody can help me !!

Thanks in advance...
Alejandro.-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
If using assigned id strategy, then you must seperately save() those two children yourself. Then add them to the parent collection.

The other option is to implement Interceptor.isUnsaved() and come up with some way to determine whether those new children are new.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 12:11 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Or set unsaved-value on <version> or <timestamp> mappings.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 7:57 am 
Newbie

Joined: Wed Jan 28, 2004 5:21 pm
Posts: 18
Location: Maracaibo, VZLA
Thank you for all, but sorry Christian I'm new using hibernate (That's the reason I'm looking a source code example) and I don't understand you very much when you say I can use unsave-value <version> .
I've seem some example that use unsave-value = "0" in the mapping file, but I've never seem how to use it in the app...

Thanks for your time
Regards,
Alejandro.-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 8:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/hib_docs/refer ... child.html

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 2:55 pm 
Newbie

Joined: Wed Jan 28, 2004 5:21 pm
Posts: 18
Location: Maracaibo, VZLA
Thanks Christian.... !!!

Alejandro.-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 5:07 pm 
Newbie

Joined: Wed Jan 28, 2004 5:21 pm
Posts: 18
Location: Maracaibo, VZLA
Hi, and sorry again, now I have a doubt if I have a composite identifiers, for example:

<composite-id name="idDetUserGroupPK" class="com.security.impl.DetUserGroupPKImpl">
<key-property
name="idUser"
column="idUser"
type="int"
length="10"
/>
<key-property
name="idGroup"
column="idGroup"
type="int"
length="10"
/>
</composite-id>


and I want to add the unsaved-value="null" param to specify the identifier value of a newly instantiated instance, do I have to put it in every key-property that I have ?? I mean, Do I have to do this :

<composite-id name="idDetUserGroupPK" class="com.security.impl.DetUserGroupPKImpl">
<key-property
name="idUser"
column="idUser"
type="int"
length="10"
unsaved-value="null"
/>
<key-property
name="idGroup"
column="idGroup"
type="int"
length="10"
unsaved-value="null"
/>
</composite-id>


or where Do I have to put the unsaved-value param ???

Thank in advance,
Alejandro.-


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