tags:

views:

64

answers:

1

i want to write to database table which has composite id using NHibernate.This is the code that i used.but it didnt 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>

appriciate quick response

regards shashi

A: 

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