-->
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.  [ 1 post ] 
Author Message
 Post subject: insert new parent/child row. How to handle primary/for key
PostPosted: Tue Nov 10, 2009 6:22 pm 
Newbie

Joined: Sat Oct 17, 2009 7:34 am
Posts: 9
Hi I have a parent object
Its primary key is auto increment field in MYSQL
This is simply pare
ntID

now parent ID also exists in the child object as a foreign Key

So inserting Parent works fine
Inserting child has a blank parent ID in its foreign key field
I do not have foreign key constraint in place on the database as i would get a foreign key constraint error then

But how can I get Hibernate to insert a row, pick up on the new primary key, set that key in the child rows

my child rows are a List in the parenet. The list is set to cascade="all"

I am saving by
session.save(parent)
session.commit();

Can give working sample code or link to a comprehenise example please


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.