I have a order table and a line item table. I have this mapped out so that the order has a bag of line items. It is as follows:
Code:
<class name="testing.Common.DataObjects.CoOrder,testing.Common.DataObjects" table="CO_Order">
<id name="OrderID" column="pk_Ord_OrderID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="Ord_TotalPrice" type="Double" name="TotalPrice" />
<property column="Ord_ShippingCost" type="Double" name="ShippingCost" />
<property column="Ord_ShippingStatus" type="String" name="ShippingStatus" length="500" />
<property column="Ord_ShippingStatusDescription" type="String" name="ShippingStatusDescription" length="1000" />
<property column="Ord_PaymentStatus" type="String" name="PaymentStatus" length="1000" />
<property column="Ord_TaxCost" type="Double" name="TaxCost" />
<property column="Ord_DateLastUpdated" type="DateTime" name="DateLastUpdated" />
<many-to-one name="User" column="fk_Ord_UserID" class="testing.Common.DataObjects.CoUser,testing.Common.DataObjects" />
<property column="Ord_DateCreated" type="DateTime" name="DateCreated" />
<many-to-one name="Payment" column="fk_Ord_PaymentID" class="testing.Common.DataObjects.CoPayment,testing.Common.DataObjects" />
<many-to-one name="ShipToAddress" column="fk_Ord_ShipToAddressID" class="testing.Common.DataObjects.CoAddress,testing.Common.DataObjects" />
<many-to-one name="BillToAddress" column="fk_Ord_BillToAddressID" class="testing.Common.DataObjects.CoAddress,testing.Common.DataObjects" />
<many-to-one name="Merchant" column="fk_Ord_MerchantID" class="testing.Common.DataObjects.CoMerchant,testing.Common.DataObjects" />
<bag name="LineItem" table="Co_LineItem" cascade="save-update-delete" >
<key column="fk_LItem_OrderID"/>
<one-to-many class="testing.Common.DataObjects.CoLineItem,testing.Common.DataObjects"/>
</bag>
<property column="Ord_OrderStatus" type="String" name="OrderStatus" length="100" />
</class>
The line item mapping is as follows:
Code:
<class name="testing.Common.DataObjects.CoLineItem,testing.Common.DataObjects" table="CO_LineItem">
<id name="LItemID" column="pk_LItem_LItemID" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="LItem_Qty" type="Int32" name="Qty" />
<property column="LItem_Price" type="Double" name="Price" />
<many-to-one name="Product" column="fk_LItem_ProductID" class="testing.Common.DataObjects.CoProduct,testing.Common.DataObjects" />
<many-to-one name="Order" column="fk_LItem_OrderID" class="testing.Common.DataObjects.CoOrder,testing.Common.DataObjects" />
</class>
When I attemp to do a Save or SaveOrUpdate on the order with line items added I recieve an incorrect # of rows affected error. The strange thing is that SaveOrUpdateCopy works. Can anyone explain why this may be occuring.