I have a crossing table that translate some data through 2 different DB
In the first DB i have a table
tableA
----------------
id_userA
city_code
(other not important field)
In the second DB the city code is structured in a different mode
tableB
----------------
id_userB
city_cod1
city_cod2
city_cod3
(other not important field)
The anagraphic of the cities is in the first DB so I created a translation table that match the 3 codes of the second DB to the code of the first DB
translate_table
----------------
city_code (PK)
city_cod1
city_cod2
city_cod3
city_cod1, city_cod2, city_cod3 as an index (unique)
This table makes only a translation of the coding between the two different DB
I tryed different configuration like
in tableB .hbm.xml
<property name="cityCod1" type="java.lang.String" column="city_cod1" length="3" />
<property name="cityCod2" type="java.lang.String" column="city_cod2" length="3" />
<property name="cityCod3" type="java.lang.String" column="city_cod3" length="3" />
<properties name="codB">
<property name="cityCod1" column="city_cod1" insert="false" update="false"/>
<property name="cityCod2" column="city_cod2" insert="false" update="false"/>
<property name="cityCod3" column="city_cod3" insert="false" update="false"/>
</properties>
<join table="translate_table">
<key property-ref="codB" not-null="true" >
<column name="city_cod1" />
<column name="city_cod2" />
<column name="city_cod3" />
</key>
<many-to-one name="tableA" class="tableA" not-null="true" column="city_code" />
</join>
but i have this error
Configuration problem: Foreign key (FKABD26E567A5262DA:translate_table [city_cod1,city_cod2,city_cod3])) must have same number of columns as the referenced primary key (tableB [id_userB])
How i can modelling this Database structure
Thanx Ivan
|