-->
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.  [ 5 posts ] 
Author Message
 Post subject: Saving a large tree
PostPosted: Tue Oct 21, 2003 4:17 pm 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
I have a tree of related entities, like so:

Module
|-ReportModule
|-Report
|-ReportFields .....

It is a configuration that I have cloned from another users configuration. I want to persist this (copy a users confuguration). What is the best way to do this?

Do I have to traverse the tree and methodically call save, update on all the nodes?

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 5:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Did you look at the cascade attruibute in relationship tags ?
cascade="save-update" might be appropriate to you

_________________
Emmanuel


Top
 Profile  
 
 Post subject: question about a cascade
PostPosted: Thu Oct 23, 2003 12:11 am 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
The hibernate docs say you have to save an entity before you can save the relationship to a parent entity...

This always confuses me about cascades, just when I think I have them figured out, I don't.

If I have a large tree, and I have cascade="all" and I call session.save(Parent) will it save all the chillen?

Thanks,

matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 1:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Thats the whole point of cascades isn't it??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 10:12 am 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
Of course your right, I think my problem is I am calling clone() on a large tree and looping through all the children and setting the keys=null in the hopes that when I save the parent it will save the tree. It is not, it is only saving the top node of the tree.

I am guessing at this point that the cloned() objects have some internal ID that the session is getting confuded on?


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