-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problems using Save & SaveOrUpdate
PostPosted: Fri Oct 21, 2005 11:27 am 
Newbie

Joined: Fri Oct 21, 2005 11:22 am
Posts: 1
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 22, 2005 5:41 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
You marked your classes generator as assigned; are you sure that you really assigned them (to a value != to 0) before?

If it is not the problem, can you post the code you are running?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.