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.  [ 4 posts ] 
Author Message
 Post subject: 1:n association with composite keys
PostPosted: Mon Dec 06, 2004 12:02 pm 
Newbie

Joined: Fri Oct 29, 2004 4:25 am
Posts: 7
hi there,

i am trying to solve the following problem for the last 2 days...

1.Table Prozess
Code:
p_id (number)
p_version (number)

p_id + p_version = compisite key


2.Table Task
Code:
t_id (number)
p_id (number)
p_version (number)

t_id = primary key


now i want hybernate to create a Prozess with a set of all Tasks that has the same p_id and the same p_version like my prozess i am loading.

how can i realize that ?

the problem seems to be that i am loading an Objekt prozess and want to refer to the foreign key of another table...

what do i have to use to make this thing work....

thanks for your time !
Jens


Top
 Profile  
 
 Post subject: Use find
PostPosted: Mon Dec 06, 2004 12:21 pm 
Newbie

Joined: Fri Dec 03, 2004 4:41 pm
Posts: 15
Just have hibernate do a find of all the matching Tasks with those two keys. Is the mapping failing for any reason?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 12:26 pm 
Newbie

Joined: Fri Oct 29, 2004 4:25 am
Posts: 7
thanks for the reply...

how can i do that ?

until now i always worked with primary keys, and not with composite keys. how can i tell hibernate to fetch all task where those two columns are equal ?

do you have an example ? could you post some xml for me ?

thanks for your help !

Jens


Top
 Profile  
 
 Post subject: SOLUTION FOUND it seems
PostPosted: Mon Dec 06, 2004 1:25 pm 
Newbie

Joined: Fri Oct 29, 2004 4:25 am
Posts: 7
hi there...

it looks like i found the solution...
i hope not to find any bugs within the next days...
anyway, just for those who were interested, this is a part of the mapping files i used...

Table Prozess
Code:
....
<set name="Tasks">
    <key >
<!--The following columns are those
that represent my compositeKey   -->
    <column name="PROZESS_ID"/>
    <column name="PROZESS_VERSION"/>         
    </key>
    <one-to-many class="Task"/>      
</set>
....


Table Task
Code:
....
<property name="prozessID" column="PROZESS_ID" />
<property name="prozessVersion" column="PROZESS_VERSION" />
......


it looks so damn easy...

cu Jens


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