-->
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.  [ 1 post ] 
Author Message
 Post subject: composite-id
PostPosted: Sun Jul 10, 2005 1:53 pm 
Newbie

Joined: Sun Jul 10, 2005 1:33 pm
Posts: 1
I am having problems saving my cross table for my many-to-many relationship. The table has additional fields so this isnt a simple m2m. Since my cross table has a dual column PK, the 2 FK ids, I am using composite-id.
Whats happening when I save is NH creates an UPDATE instead of INSERT. Ok, so I need a saved-value, but when i tried 'null' it returned a schema error. (looking in the code tehre is support for saved-value="null" it need to be added to the schema.) Using null wont work anyways becuase my composite isnt null it has the values I want to link.

Am I using the composite-id correctly? If I am, then how do i tell NH that my composite class is new vs updated?


cross table hbm:
Code:
   <class name="ChangeOrder.Domain.CoEquipmentLocationProducts,ChangeOrder.Domain" table="CO_EQUIPMENT_LOCATION_PRODUCTS">
   
      <composite-id name="OrderSection" class="ChangeOrder.Domain.OrderSection,ChangeOrder.Domain" unsaved-value="null">
         <key-many-to-one name="ChangeOrderId" column="CHANGE_ORDER_ID" class="ChangeOrder.Domain.CoChangeOrder,ChangeOrder.Domain"/>
         <key-many-to-one name="FormSectionId" column="FORM_SECTION_ID" class="ChangeOrder.Domain.CoFormSection,ChangeOrder.Domain"/>
      </composite-id>
      
      <many-to-one name="BaseProductId" column="BASE_PRODUCT_ID" class="ChangeOrder.Domain.CoBaseProduct,ChangeOrder.Domain" />
      <many-to-one name="EquipmentLocationId" column="EQUIPMENT_LOCATION_ID" class="ChangeOrder.Domain.CoEquipmentLocation,ChangeOrder.Domain" />
      
   </class>



composite class:
Code:

   public class OrderSection
   {
      private CoChangeOrder order_section;
      private CoFormSection form_section;    

      public OrderSection()
      {
         order_section = null;
         form_section = null;
         order_section_id = 0;
         form_section_id = 0;
      }
      public CoChangeOrder ChangeOrderId
      {
         get { return order_section; }
         set {order_section = value; }
      }
      public CoFormSection FormSectionId
      {
         get { return form_section; }
         set {form_section = value; }
      }
      public override bool Equals( object obj ) {...}
      public override int GetHashCode() {...}
   }


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

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.