-->
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: property-ref for key-many-to-one
PostPosted: Thu Apr 28, 2005 9:35 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
Hibernate version:
3.0

Mapping documents:

<composite-id name="comp_id" class="RequestPK">
<meta attribute="field-description" inherit="false">@hibernate.id generator-class="assigned"</meta>
<key-many-to-one name="requestAn" class="RequestAn" property-ref="alternateKeys">
<column name="REQUEST_ID" />
<column name="REQUEST_ANS_IX" />
</key-many-to-one>
<key-many-to-one name="rptd" class="Rptd">
<column name="RPTD_ID" />
</key-many-to-one>
</composite-id>

I just want to use not the PK but an alternate, unique key for constructing the part of the composite-id.
Is something like that example possible (maybe in near future)? Or is there another way to do it?
Thanks in advance!


Top
 Profile  
 
 Post subject: Composite key: FK + id-generator?
PostPosted: Mon May 02, 2005 2:58 am 
Beginner
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!


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.