-->
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.  [ 7 posts ] 
Author Message
 Post subject: Composite key mapping question - strange scenario
PostPosted: Tue Jun 15, 2004 4:34 am 
Newbie

Joined: Tue Jun 08, 2004 12:04 am
Posts: 12
Hi,

What is the most efficient way to map this scenario?

Table A (Composite PK)
---------
PK_A1
PK_A2
PK_A3

Table B (C, D, E as well, but B is representative) (Composite keys)
---------
FK_B1 (corresponds to PK_A1)
FK_B2 (corresponds to PK_A2)
FK_B3 (corresponds to PK_A3)

Table F (Composite keys)
--------
FK_F1 (corresponds to PK_A1)
FK_F2 (corresponds to PK_A2)

Table A maps well (as one-to-many) to table B,C,D,E. That's no problem
However, how would I map to Table F too? Seems like Hibernate is complaining the fact that the keys are not matching up well.

Please kindly provide some insight, thanks!

-RS


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 7:57 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can map the relathionship between A F, where is the problem?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 4:02 pm 
Newbie

Joined: Tue Jun 15, 2004 3:52 pm
Posts: 4
I am having a similar problem defining a mapping. Can you shed some light on how to define a mapping with these rules?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 4:44 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
1- show what is the domain model you wish, simply explaining what relations you want
2- think about unique business identity (not necessary db primary key)
3- tell why you can't do it

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 4:53 pm 
Newbie

Joined: Tue Jun 15, 2004 3:52 pm
Posts: 4
1. domain model is exactly the same as in the original post. Table A has a composite key with 3 elements, Table B has a composite key with 2 elements, with Table B's key mapping to 2 elemetns within Table A.

2. From a programming perspective I want to have an instance of my Table B DTO within my Table A DTO, using hibernate to load the correct instance.

3. I don't know how to map composite keys in a one-to-one mapping. The documentation only explains how to map on 1 field.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 1:30 am 
Newbie

Joined: Tue Jun 08, 2004 12:04 am
Posts: 12
I think a composite key mapping guide will be seriously helpful.

For my case, I am able to map one-to-many from A to B (C, D, E, etc)
However, I can't map (one-to-many) A to F because everytime I do so it throws runtime error.

I am asking, in the general sense, if the parent, A has 3 columns as composite keys, and of which 2 columns are being used as foreign keys to map to F. Is it doable? (It throws runtime error everytime I tried)

If you're able to do so, do you mind to provide a mapping file example?

A is the parent to B, C, D, E, F (all of them is one-to-many association)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 2:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
1- domain model is not relationnal model!
please give a *--1 b 1--1 c for example, i don't have time to think about which domain model might be ok for your relationnal model

2- think twice about using one to one, can't it be a many-to-one ? if it is simplier for you to use a many-to-one (which might not change business constraints), go for it.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.