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>
精彩评论