简体   繁体   English

NHibernate 2.0将Composite-ID映射到Composite-ID内

[英]NHibernate 2.0 mapping a composite-id inside a composite-id

I have a table1 TAS with: 我有一个table1 TAS:

<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. 表STAS是一个复合ID。 It's a TAS key (that is a composite-id) and another Key. 它是一个TAS密钥(是一个复合ID)和另一个密钥。 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]) 外键(FK451D68E632669A4:NCPTB017_STAS [NU_TAS_016]))的列数必须与引用的主键(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 ??? 为了更简单,我如何映射具有复合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... 例:Table1具有一个复合ID Id1和Id2 Table2具有来自table1的多对一,因为它具有一个复合FK,其中包含来自table1的Id1和Id2 ...

Thanks for helping! 感谢您的帮助!

never used it, but I would say like this: 从未使用过,但我会这样说:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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