-->
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.  [ 2 posts ] 
Author Message
 Post subject: Parent and Child Issue
PostPosted: Thu Apr 19, 2007 10:31 pm 
Newbie

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 1
Location: Hyderabad
Hi

Please find the Image here : http://ramsateesh.googlepages.com/index.html

I have a persistant object of the parent and I have my mapping file which allows hibernate to create the parentId (primary key). But I have a list of child objects embedded in the parent object which have parentId as their foreign Key. I have cascade all in my parent.hbm.xml file.

When I am doing session.save(parent), I am getting an exception saying that I am trying to insert data into child with parentId value eq null.

I tried to debug the code by removing cascade all from the parent mapping file. Right after a successful save of parent I thought it would update the parentId in the children but it didn't and I think that's the reason why it's failing to insert data when cascade all option was present in the parent mapping file.

Can someone help me solving this problem, what do I have to do so that when I save my parent my child records also get saved.[/img]

_________________
Ram Sateesh
Consultant


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 11:44 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Hi,

It's a little odd that you have both parentId and parent Object in the Child. You should need only the Object really.

Anyway is your parentId in the child set? is it a required field i.e nullable=false? From the ER diagram it looks like its required. If it's required you need to explicitly set it before saving the parent (which will cascade to the child)


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