Hibernate version: NHibernate1.2.0Beta 2
Name and version of the database you are using: SQL Server 2000
The generated SQL (show_sql=true): n/a
I have the following mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HELM.Domains.Orderlines,HELM.Domains" table="orderlines" lazy="false">
<!--<id name="Orderid" column="OrderID" type="System.Int32" unsaved-value="any" >
<generator class="assigned"/>
</id>-->
<composite-id access="field">
<key-property name="WarehouseId" column="WarehouseID" type="System.Int32"/>
<key-property name="ItemId" column="ItemId" type="System.Int32"/>
<key-property name="OrderLineid" column="OrderLineID" type="System.Int32" />
</composite-id>
<!--<property column="OrderLineID" name="OrderLineid" type="System.Int32"/>-->
<property column="ActualWeight" type="System.Decimal" name="ActualWeight" />
<!-- Relationships-->
<many-to-one name="Items" class="HELM.Domains.Inventory,HELM.Domains" cascade="none" update="false" insert="false">
<column name="Warehouseid"/>
<column name="ItemId"/>
</many-to-one>
</class>
</hibernate-mapping>
I am getting an error when I try to save the Orderline object. The error is:
NHibernate.ADOException: could not insert: [HELM.Domains.Orderlines#HELM.Domains.Orderlines][SQL: INSERT INTO orderlines (OrderID, ActualWeight, Warehouseid, ItemId, WarehouseID, ItemId, OrderLineID) VALUES (?, ?, ?, ?, ?, ?, ?)] ---> System.Data.SqlClient.SqlException: Column name 'WarehouseID' appears more than once in the result column list.
Column name 'ItemId' appears more than once in the result column list..
How do I specify both a composite key, and a relationship to a table with a composite key without nhibernate trying to persist fields that are common to both the key and the relationship each time they appear?