Beginner |
|
Joined: Mon Apr 11, 2005 8:37 am Posts: 22
|
Is there anybody that can help me?
Maybe I should demonstrate the problem more generalized.
I got a table A:
PK_A - primary key
I got another table B:
PK_A - FK pointing to A; part of PK
INDEX_B - an index to allow one-to-many relations between A and B; part of PK
And finally there is another table C that allows associations between two instances of B:
PK_A_1 - FK1 pointing to B
INDEX_B_1 - FK1 pointing to B
PK_A_2 - FK2 pointing to B
INDEX_B_2 - FK2 pointing to B
(all part of PK)
+ other properties
How can I do this?
Roughly my approach:
table A - no problems
table B:
- defining INDEX_B as PK alone (in order to use a id-generator)
- using a many-to-one relation to PK_A
- defining a unique <properties> consisting of INDEX_B and PK_A (even if INDEX_B is unique itself) to allow referencing by many-to-one from C
table C:
- I used twice a many-to-one with property-ref pointing to the unique pair in B
==> I got no id in C, because in key-many-to-one I can only reference the PK of another class
Now two solutions I could imagine:
1. using a property-ref in key-many-to-one;
@hibernate-team: Is there any reason why that should not be possible?
2. some way to construct an composite id consisting of a foreign key and another properties for which an id-generator can be used;
is this possible? Please give me a hint, I can't get any further on the problem...
Thanks a lot!
|
|