views:

84

answers:

0

I am not able to save the many to one composite foreign key value. PricingSheetFeeLineItem has one-to-many relation with SaleObjectPricingSheet. saleObjectPricingSheet has composite primary key. When I called session.saveOrUpdate(aPricingSheetFeeLineItem), the value for saleObjectPricingSheet is not able to be caught by hibernate so the DB insert statement are always missed SaleObjectPricingSheet. The sample sql statement is as follows:

/*  insert PricingSheetFeeLineItem  WHERE saleObjectPricingSheet is not able to be saved */ 
       insert 
        into
            RATINGS.PRICING_SHEET_FEE_LINE_ITEM
            (CURRENT_FEE_TYPE_OVERRIDE_REASON_ID, PRICING_SHEET_ID, BILLABLE_ACTIVITY_ID, FEE_SCHEDULE_FEE_TYPE_ID) 
        values
            ( ?, ?, ?, ?)

mapping for PricingSheetFeeLineItem (there are total 5 columns in the mapping table):

<class name="PricingSheetFeeLineItem" table="PRICING_SHEET_FEE_LINE_ITEM" schema="RATINGS"> 
              :
              :       
    <many-to-one name="saleObjectPricingSheet"  class="SaleObjectPricingSheet" insert="false" update="false">
        <column name="PRICING_SHEET_ID" not-null="true" />
        <column name="SALE_OBJECT_ID" not-null="true" />
    </many-to-one> 
              :
</class>
</hibernate-mapping>

mapping for SaleObjectPricingSheet:

<class name="SaleObjectPricingSheet" table="SALE_OBJECT_PRICING_SHEET">
    <composite-id name="id" class="SaleObjectPricingSheetId">
        <key-property name="pricingSheetId" type="java.lang.Long">
            <column name="PRICING_SHEET_ID" />
        </key-property>
        <key-property name=saleObjectId" type="java.lang.Long">
            <column name="SALE_OBJECT_ID" />
        </key-property>
    </composite-id>
    <set name="pricingSheetFeeLineItems" inverse="true">
        <key>
            <column name="PRICING_SHEET_ID" not-null="true" />
            <column name="SALE_OBJECT_ID" not-null="true" />
       </key>
        <one-to-many class="PricingSheetFeeLineItem"/>
   </set>
</class>
</hibernate-mapping>

Please advice