-->
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: How to save Child with Parent and Subchild
PostPosted: Wed Mar 25, 2009 3:33 am 
Newbie

Joined: Wed Mar 25, 2009 3:23 am
Posts: 2
Hi Everyone!
I have three table:
1: Parent
2: Child
3: Subchild1
4: Subchild2
and relationship between them are
Parent:Child is 1:n
Child: Subchild1 is 1:n
Child: Subchild2 is 1:n

I can save child with parent, subchild1 with child and parent. But, I cannot save Child with Subchild1 and Subchild2. So, is there any solution to save Child with all subchilds?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 25, 2009 7:18 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
uhm... cascade = "all" for the set/map/bag containing subchild1 and 2?

So you should be able to do:

Code:
Child child = new Child();
child.subChilds1.Add(new SubChild1());
child.subChilds1.Add(new SubChild1());

child.subChilds2.Add(new SubChild2());
child.subChilds2.Add(new SubChild2());

Session.Save(child);
Session.Flush();


If that doesn't help please post your classes and the associated mapping files.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 25, 2009 9:32 pm 
Newbie

Joined: Wed Mar 25, 2009 3:23 am
Posts: 2
Thank reflection !
It's greate! Now I can do that!


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.