开发者

C# with Nhibernate

开发者 https://www.devze.com 2022-12-14 10:55 出处:网络
I want to write to database table which has composite id using NHibernate. This is the code that I used, but it didn\'t work.

I want to write to database table which has composite id using NHibernate. This is the code that I used, but it didn't work.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernatePets.junctionstatistic,开发者_如何学运维 NHibernatePets" lazy="true">
<composite-id>
  <key-property name="junctionid" column="junctionid" type="int" />
  <key-property name="roadid" column="roadid" type="int" />
</composite-id>

// other properties

</class>
</hibernate-mapping>


My guess is your PropertyName does not match the physical property name on your class.

Here is what I do:

<composite-id>
        <key-property name="CustomerNumber"/>
        <key-property name="OrderNumber"/>
</composite-id>
        <property name="CustomerNumber">
        <column name="customerId" sql-type="numeric(20,10)"/>
    </property>
        <property name="OrderNumber">
        <column name="orderId" sql-type="numeric(20,10)"/>
    </property>
0

精彩评论

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