-->
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: Parent and Child Objects!
PostPosted: Tue Mar 01, 2005 7:21 am 
Newbie

Joined: Thu Feb 24, 2005 8:49 am
Posts: 6
Hi All,

This is related to persistence of parent and child objects, where the child object shares the primary key with its parent's primary key. When I am trying to save the parent along with children, it throws exception saying, the child should populate the primary key id, but I cannot populate since it parent is still not created and get created along with child.

If I save parent and then save child separtly, it goes fine otherwise no.

Also, I heard this attribute named "constrained" and "generator=forign" but not sure whether they gonna help me.

You suggestions are highly appreciated.

Thanks,
Arshad





Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Re: Parent and Child Objects!
PostPosted: Tue Mar 01, 2005 12:51 pm 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
arshad_nj wrote:
...the child object shares the primary key with its parent's primary key.

The child should have its own PK, and reference the parent with a FK.


Top
 Profile  
 
 Post subject: It is composite primary and shares with parent!
PostPosted: Thu Mar 03, 2005 2:20 am 
Newbie

Joined: Thu Feb 24, 2005 8:49 am
Posts: 6
thanks for your response, what I mean by sharing the primary key is, the child got a composite primary key and primary key of the parent is one of the attribute of the child primary key.

Please, see the below topic for the complete details about this problem:

http://forum.hibernate.org/viewtopic.php?t=939169

Thanks,
Arshad


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.