| Author |
Problem with joining of two tables with Hibernate
|
Sverre Moe
Ranch Hand
Joined: Jul 10, 2007
Posts: 98
|
|
I have a Hibernate mapping against a database table which is working. However I have another table which contains extra information. I've tried a join in the mapping file but somehow it fails. Lets call them Table1 og Table2. Table1 has an attribute TAB1_Var_ID(not a primary key) Table2 has a primary key TAB2_Var_ID which is connected to the TAB1_Var_ID There is a many-to-one relationship. Table1 can contain many TAB2_Var_ID I am fairly new with Hibernate and don't have a clue what the cause of my problem is. Heres is my join mapping The Class for Table1 inherits from a parent class which contains some of the values retrieved from persistence. tab1VarID is an variable in the parent class. The error message I get from UnitTest is a MappingException
Foreign key (Table2 [TAB2_Var_ID]) must have same number of columns as the referenced primary key (Table1 [primaryKey1, primaryKey2, primaryKey3])
But I thought that property-ref "Specifies that the foreign key refers to columns that are not the primary key of the orginal table.". And the original table is Table1. Or is it? Edit: I receive the same error with and withouth the property-ref in <key> It seems that the tables are reversed. It is saying something about the foreign key which is in Table2. But the foreign key is in Table1. TAB1_Var_ID in Table1 is not defined as a foreign-key in the SQL level. That is a database design I cannot meddle with [ August 06, 2007: Message edited by: Sverre Moe ]
|
 |
 |
|
|
subject: Problem with joining of two tables with Hibernate
|
|
|