-->
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: Wrong / No FK in DB, joining still possible?
PostPosted: Mon Nov 30, 2009 2:29 pm 
Newbie

Joined: Mon Nov 30, 2009 2:19 pm
Posts: 7
Hi!

I have to work an a legacy data base here. I have two tables which should be linked together with a FK, but there is none. So the data import used the wrong columns to link the two tables together (not the PK column in the child table).

table_1 (
t1_id PK int,
t2_id varchar(20) --> this should be a FK column with a constraint to table_2.t2_id, but the values in here point to table_2.some_value1!
)

table_2 (
t2_id PK int,
some_value1 varchar(20)
some_value2 varchar
)

there should be the FK constraint on table_1.t2_id, but it is not. In the table_t1 column are values which link to the table_2.some_value1 field. the values in table_2.t2_id and table_2.some_value1 are unique, so it should be possible to navigate, but I have no idea how to do the mapping. How can I tell hibernate to use table_2.some_value1 to join the tables, instead of using table_2.t2_id?

thanks in advance for your help!

best regards,
mongole


Top
 Profile  
 
 Post subject: Re: Wrong / No FK in DB, joining still possible?
PostPosted: Tue Dec 01, 2009 4:04 am 
Newbie

Joined: Mon Nov 30, 2009 2:19 pm
Posts: 7
Thanks, I found the solution allready.

It's very good described in th "Java Persistance with Hibernate" Book in Chapter 8.


Greets,
Mongole


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.