开发者

NHibernate one-to-one with composite-id problem

开发者 https://www.devze.com 2022-12-30 02:53 出处:网络
My error mess开发者_运维技巧age: NHibernate.MappingException : broken column mapping for: ItemDetails.id of: NHibReg.Domain.RegDetail, type Int32 expects 1 columns, but 2 were mapped

My error mess开发者_运维技巧age:

NHibernate.MappingException : broken column mapping for: ItemDetails.id of: NHibReg.Domain.RegDetail, type Int32 expects 1 columns, but 2 were mapped

I get this when I try to get a RegDetail row: How can I solve this?

Here is the RegDetail MAP:

<class name="RegDetail" table="******">

  <composite-id>
    <key-property name="RegistryNum" column="****" type="int"/>
    <key-property name="Sku" column="****" type="int"/>
  </composite-id> 

  <property name="QtyRequested" column="****" type="int"/>
  <one-to-one name="ItemDetails" class="Item"/>

</class>

Here is the Item MAP:

<class name="Item" table="Items">

  <id name="Sku" column="SKU" type="int"/>
  <property name="StyleDescrip" column="*****" type="String"/>

</class>


I'm going to say you should try to do a Join rather than One-to-One. Something like this: Fluent NHibernate - Map 2 tables to one class.

I'm not sure how 1:1 could work with different keys in the two entities.

0

精彩评论

暂无评论...
验证码 换一张
取 消