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
|