2009-12-22 33 views
0

我想寫入數據庫表使用NHibernate複合id。這是我使用的代碼,但它不起作用。C#與Nhibernate

<?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> 
+0

什麼沒有工作? – Rippo 2009-12-22 10:41:46

+0

你的問題到底是什麼? – 2009-12-22 10:41:55

+1

發佈你的類定義的代碼 – 2009-12-22 10:43:35

回答

0

我的猜測是你的PropertyName與你的類的物理屬性名稱不匹配。

這裏是我做的:

<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>