简体   繁体   中英

NHibernate 2.0 mapping a composite-id inside a composite-id

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!

never used it, but I would say like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM