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
|
|