views:

43

answers:

1

I have a table1 TAS with:

<class name="TAS" table="NCPTB016_TAS">
<composite-id>
  <key-many-to-one column="NU_MACRO_PROCESSO_007" name="MacroProcesso"/>
  <key-property column="NU_TAS" name="Id" />
</composite-id>
... //and some other properties

And i have a table that is:

<class name="STAS" table="NCPTB017_STAS">
<composite-id>
  <key-many-to-one column="NU_MACRO_PROCESSO_016" name="MacroProcesso"/>
  <key-many-to-one column="NU_TAS_016" name="TAS" />
  <key-property column="NU_STAS" name="Id" />
</composite-id>
... //some properties

The table STAS is a composite-id. It's a TAS key (that is a composite-id) and another Key. How do i map that? When i do the way i am doing i got an error:

Foreign key (FK451D68E632669A4:NCPTB017_STAS [NU_TAS_016])) must have same number of columns as the referenced primary key (NCPTB016_TAS [NU_MACRO_PROCESSO_007, NU_TAS])


To be more simple, how do i map a Many-to-one that have a composite-id ???

Ex: Table1 has a compososite-id Id1 and Id2 Table2 has a many-to-one from table1, since it have a composite FK with Id1 and Id2 from table1...

Thanks for helping!

+1  A: 

never used it, but I would say like this:

<many-to-one ...>
  <column name="key1" />
  <column name="key2" />
</many-to-one>
Stefan Steinegger