-->
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: Multiple one-to-one Relationships
PostPosted: Thu Jan 10, 2008 9:31 am 
Newbie

Joined: Thu Jan 10, 2008 8:39 am
Posts: 7
Hibernate version: 1.2

Problem Statement:

I'm stuck with the following scenario:

I have one parent with a primary key. Now parent's Primary Key is mapped to two Child objects and is also their Primary Key.

Hibernate provides a way to map one-to-one between two objects. In that case if I create a "Child" object then hibernate will automatically create a "Parent" object by using Parent key.

But the problem is with one "Parent" and two "Child", parent and both children must have same ID and must always be created in single transaction.

_____________
| Parent
|------------------
| pid (PK)
| text
|_____________


_____________
| Child1
|------------------
| pid (FK + PK)
| textC1
|_____________


_____________
| Child2
|------------------
| pid (FK + PK)
| textC2
|_____________

Thanking in advance for your wise replies


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 10:32 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
Maybe I misunderstand you but... In an one-to-one relationship you cannot have a parent with two/many children. You need an one-to-many relationship.


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.