-->
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: hbm.xml file does an update instead of an insert- Helppppp
PostPosted: Mon Oct 29, 2007 3:28 pm 
Newbie

Joined: Sun Oct 28, 2007 1:21 am
Posts: 5
Greetings,

I really need help on this. I am trying to use Hibernate to insert on two table on the database. The relation is of type Parent/Child. The problem is that it inserts well on the Parent table but on the Child table it doesn't insert.

Debuging through the project I've found out that he makes an INSERT for the first table but for the second table it makes an UPDATE.

The hbm.xml files that I've built are bellow, the first file has lot of thing but what is used for these tables is at the end:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class name="com.retek.rpm.domain.promotion.bo.PromotionComponentDetailImpl"
        table="RPM_PROMO_COMP_DETAIL" dynamic-update="true"
        persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister">
        <composite-id name="objectId" class="com.retek.platform.bo.LongObjectId" access="field"
            unsaved-value="any">
            <key-property name="value" column="RPM_PROMO_COMP_DETAIL_ID" type="long"
                access="field"/>
        </composite-id>
        <many-to-one name="promotionComponent"
            class="com.retek.rpm.domain.promotion.bo.PromotionComponentImpl" column="PROMO_COMP_ID"
            not-null="true" access="field"/>
        <property name="displayId" column="PROMO_COMP_DETAIL_DISPLAY_ID" not-null="true"
            type="string"/>
        <property name="ignoreConstraintHandling" column="IGNORE_CONSTRAINTS"
            type="boolean"/>         
        <property name="promotionApplyCode" column="APPLY_TO_CODE" not-null="true"
            type="com.retek.rpm.domain.promotion.dao.PromotionApplyCodeConverter"/>
        <property name="effectiveDateRange" access="field"
            type="com.retek.rpm.domain.calendar.dao.DateRangeUserType">
            <column name="START_DATE"/>
            <column name="END_DATE"/>
        </property>
        <property name="createDate" not-null="true" column="CREATE_DATE"
            type="com.retek.rpm.domain.calendar.dao.RDateType"/>
        <property name="createID" not-null="true" column="CREATE_ID" type="string"/>
        <property name="approvalDate" not-null="false" column="APPROVAL_DATE"
            type="com.retek.rpm.domain.calendar.dao.RDateType"/>
        <property name="approvalID" not-null="false" column="APPROVAL_ID" type="string"/>
        <property name="stateCode" column="STATE" type="string"/>
        <joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentSimpleDetailImpl"
            table="RPM_PROMO_COMP_SIMPLE" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister">
            <key column="RPM_PROMO_COMP_DETAIL_ID"/>
            <property name="merchandiseNode"
                type="com.retek.rpm.domain.promotion.dao.MerchandiseNodeUserType$All"
                access="field">
                <column name="MERCH_TYPE" not-null="true"/>
                <column name="DEPT" not-null="false"/>
                <column name="CLASS" not-null="false"/>
                <column name="SUBCLASS" not-null="false"/>
                <column name="ITEM" not-null="false"/>
                <column name="DIFF_ID" not-null="false"/>
            </property>
            <property name="zoneGroupNode"
                type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType" access="field">
                <column name="ZONE_NODE_TYPE"/>
                <column name="ZONE_ID"/>
                <column name="LOCATION"/>
            </property>
            <property name="retailChangeValue" access="field"
                type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType">
                <column name="CHANGE_TYPE" not-null="true"/>
                <column name="CHANGE_AMOUNT" not-null="false"/>
                <column name="CHANGE_CURRENCY" not-null="false"/>
                <column name="CHANGE_PERCENT" not-null="false"/>
                <column name="CHANGE_SELLING_UOM" not-null="false"/>
                <column name="TSL_VOUCHER_NUMBER" not-null="false"/>
                <column name="TSL_VOUCHER_DESC" not-null="false"/>
            </property>
            <many-to-one name="priceGuide" column="PRICE_GUIDE_ID"
                class="com.retek.rpm.domain.priceguide.bo.PriceGuideImpl" not-null="false"
                access="field"/>
            <property name="attribute1" column="ATTRIBUTE_1" type="string" access="field"/>
            <property name="attribute2" column="ATTRIBUTE_2" type="string" access="field"/>
            <property name="attribute3" column="ATTRIBUTE_3" type="string" access="field"/>
            <many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentSimpleDetailImpl"
                column="EXCEPTION_PARENT_ID" access="field"/>
        </joined-subclass>
        <joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentThresholdDetailImpl"
            table="RPM_PROMO_COMP_THRESHOLD" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister">
            <key column="RPM_PROMO_COMP_DETAIL_ID"/>
            <property name="merchandiseNode"
                type="com.retek.rpm.domain.promotion.dao.MerchandiseNodeUserType$All"
                access="field">
                <column name="MERCH_TYPE" not-null="true"/>
                <column name="DEPT" not-null="false"/>
                <column name="CLASS" not-null="false"/>
                <column name="SUBCLASS" not-null="false"/>
                <column name="ITEM" not-null="false"/>
                <column name="DIFF_ID" not-null="false"/>
            </property>
            <property name="zoneGroupNode"
                type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType" access="field" >
                <column name="ZONE_NODE_TYPE"/>
                <column name="ZONE_ID"/>
                <column name="LOCATION"/>
            </property>
            <many-to-one name="threshold" column="THRESHOLD_ID"
                class="com.retek.rpm.domain.promotion.bo.ThresholdImpl" not-null="true"
                access="field"/>
            <property name="attribute1" column="ATTRIBUTE_1" type="string" access="field"/>
            <property name="attribute2" column="ATTRIBUTE_2" type="string" access="field"/>
            <property name="attribute3" column="ATTRIBUTE_3" type="string" access="field"/>
            <property name="isExclusion" column="EXCLUSION" type="boolean" access="field"/>
            <many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentThresholdDetailImpl"
                column="EXCEPTION_PARENT_ID" access="field"/>
        </joined-subclass>
        <joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"
            table="RPM_PROMO_COMP_BUY_GET" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister">
            <meta attribute="lazy-load-collection">zoneGroupNodes</meta>
            <key column="RPM_PROMO_COMP_DETAIL_ID"/>
            <property name="all" column="BUY_ITEM_TYPE" type="boolean" not-null="true"/>
            <property name="buyQuantity" column="BUY_ITEM_QTY"
                type="com.retek.rpm.domain.promotion.dao.QuantityUserType" not-null="true"/>
            <property name="retailChangeValue" access="field"
                type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType">
                <column name="CHANGE_TYPE" not-null="true"/>
                <column name="CHANGE_AMOUNT" not-null="false"/>
                <column name="CHANGE_CURRENCY" not-null="false"/>
                <column name="CHANGE_PERCENT" not-null="false"/>
                <column name="CHANGE_SELLING_UOM" not-null="false"/>
                <column name="TSL_VOUCHER_NUMBER" not-null="false"/>
                <column name="TSL_VOUCHER_DESC" not-null="false"/>
            </property>
            <set name="buyItems" access="field" table="RPM_PROMO_BUY_ITEM" inverse="false"
                lazy="true" cascade="none" persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister">
                <key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/>
                <many-to-many class="com.retek.rpm.domain.core.bo.ItemImpl" column="ITEM"/>
            </set>
            <set name="getItems" access="field" table="RPM_PROMO_GET_ITEM" inverse="false"
                lazy="true" cascade="none" persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister">
                <key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/>
                <many-to-many class="com.retek.rpm.domain.core.bo.ItemImpl" column="ITEM"/>
            </set>
            <set name="zoneGroupNodes" access="field" table="RPM_PROMO_BUY_GET_ZONE"
                inverse="false" lazy="false" cascade="none">
                <key column="RPM_PROMO_COMP_DETAIL_ID"/>
                <element type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType">
                    <column name="ZONE_NODE_TYPE" sql-type="long"/>
                    <column name="ZONE_ID" sql-type="long"/>
                    <column name="LOCATION" sql-type="long"/>
                </element>
            </set>
            <set name="promotionComponentDetailLocationExclusions" cascade="save-update"
                access="field" inverse="false" lazy="true">
                <key column="EXCLUSION_PARENT_ID"/>
                <one-to-many
                    class="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"/>
            </set>
            <many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"
                column="EXCLUSION_PARENT_ID" access="field"/>
        </joined-subclass>

        <!--Changes for Mod 93

############################################################

                   From this point is what matters for the question that I need answers. Ignore what is above.

############################################################
        -->

       

        <joined-subclass                       
            name="com.retek.rpm.domain.promotion.bo.TslPromotionComponentMultiBuyDetailImpl"
            table="TSL_RPM_PROMO_COMP_M_B" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister">
              <meta attribute="lazy-load-collection">zoneGroupNodes</meta>
         <key column="RPM_PROMO_COMP_DETAIL_ID"/>
                                       
            <property name="multiBuyPromotionType" column="MULTI_BUY_PROMO_TYPE" type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyTypeStringCodeConverter" not-null="true"/>
            <!-- coupon to be included -->
         
         
            <set name="listDetails" inverse="true" lazy="true" cascade="save-update">
            <key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/>
            <one-to-many class="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl"/>
         </set>         
                  
   </joined-subclass>
    </class>
</hibernate-mapping>


The precious hbm.xml file has a joined-class that works fine and has a set for a collection that is doing an update instead of an INSERT.

The class that is used in the set implements the following hbm.xml file.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<!--
     modified by: Lakshmi Natarajan - LN,lakshmi.natarajan@in.tesco.com
     date: 26-April-2007 v1.0
     Mod ref: 365a
     Mod Description: Addition of new properties sTslBaseItem,bTslPriceMarkInd and bTslPrimPackInd corresponding to
                      ITEM_MASTER.TSL_BASE_ITEM,ITEM_MASTER.TSL_PRICE_MARK_IND and ITEM_MASTER.TSL_PRIM_PACK_IND
-->
       
<hibernate-mapping>
       <class name="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl" table="TSL_RPM_PROMO_COMP_M_B_DTL">         

             <id name="id" type="long" column="LIST_ID" unsaved-value="null">
                <generator class="sequence">
                      <param name="sequence">TSL_MULTI_BUY_LIST_ID_SEQ</param>
                </generator>
              </id>
              <many-to-one name="tslPromotionComponentMultiBuyDetailImpl" class="com.retek.rpm.domain.promotion.bo.TslPromotionComponentMultiBuyDetailImpl"
               column="RPM_PROMO_COMP_DETAIL_ID" not-null="true" access="field" />
                        
                <!--property name="displayId" column="LIST_DISPLAY_ID" type="string" insert="false" update="false" access="field"/-->                                 
              <property name="listTypes" column="LIST_TYPE"  type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyListTypeCodeConverter" insert="false" update="false" access="field"/>
            <property name="buyListType" column="BUY_ITEM_TYPE" type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyPromotionBuyTypeCodeConverter" insert="false" update="false" access="field"/>
            <property name="value" column="BUY_ITEM_VALUE" insert="false" update="false" access="field"/>
            <property name="retailChangeValue" access="field"
               type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType" insert="false" update="false">
               <column name="CHANGE_TYPE" not-null="false"/>
               <column name="CHANGE_AMOUNT" not-null="false"/>
               <column name="CHANGE_CURRENCY" not-null="false"/>
               <column name="CHANGE_PERCENT" not-null="false"/>
               <column name="CHANGE_SELLING_UOM" not-null="false"/>
               <column name="VOUCHER_NUMBER" not-null="false"/>
               <column name="VOUCHER_DESCRIPTION" not-null="false"/>
              </property>
               <property name="lockVersion" column="LOCK_VERSION" not-null="false" insert="false" update="false" access="field"/>
               <property name="getQuantity" column="GET_QUANTITY" type="com.retek.rpm.domain.promotion.dao.QuantityUserType" not-null="false" insert="false" update="false" access="field"/>
         </class>         
</hibernate-mapping>


Here is the SQL statements that are produced by the hbm.xml files

Code:
insert into RPM_PROMO_COMP (COMP_DISPLAY_ID, NAME, CONSIGNMENT_RATE, STATE, SECONDARY_IND, PROMO_ID, DEAL_ID_ITEM, DEAL_DETAIL_ID_ITEM,
DEAL_ID_LOCATION, DEAL_DETAIL_ID_LOCATION, FUNDING_PERCENT, BUY_GET_UPTAKE_PERCENT, PROMO_COMP_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

update TSL_RPM_PROMO_COMP_M_B_DTL set RPM_PROMO_COMP_DETAIL_ID=? where LIST_ID=?


I really need answers for:

How can I force the hbm.xml file to do an INSERT instead of an UPDATE?

Thanks for any reply

Many Thanks,
Rui FĂ©lix


Top
 Profile  
 
 Post subject: Already found the answer for my post
PostPosted: Tue Oct 30, 2007 2:35 am 
Newbie

Joined: Sun Oct 28, 2007 1:21 am
Posts: 5
Hello,

I already got the answer for my question. I had to make some changes to the TslMultiBuyListImpl.hbm.xml file. Here are the two hbm files:

Code:
   
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"&gt;

&lt;hibernate-mapping&gt;
    &lt;class name="com.retek.rpm.domain.promotion.bo.PromotionComponentDetailImpl"
        table="RPM_PROMO_COMP_DETAIL" dynamic-update="true"
        persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister"&gt;
        &lt;composite-id name="objectId" class="com.retek.platform.bo.LongObjectId" access="field"
            unsaved-value="any"&gt;
            &lt;key-property name="value" column="RPM_PROMO_COMP_DETAIL_ID" type="long"
                access="field"/&gt;
        &lt;/composite-id&gt;
        &lt;many-to-one name="promotionComponent"
            class="com.retek.rpm.domain.promotion.bo.PromotionComponentImpl" column="PROMO_COMP_ID"
            not-null="true" access="field"/&gt;
        &lt;property name="displayId" column="PROMO_COMP_DETAIL_DISPLAY_ID" not-null="true"
            type="string"/&gt;
        &lt;property name="ignoreConstraintHandling" column="IGNORE_CONSTRAINTS"
            type="boolean"/&gt;         
        &lt;property name="promotionApplyCode" column="APPLY_TO_CODE" not-null="true"
            type="com.retek.rpm.domain.promotion.dao.PromotionApplyCodeConverter"/&gt;
        &lt;property name="effectiveDateRange" access="field"
            type="com.retek.rpm.domain.calendar.dao.DateRangeUserType"&gt;
            &lt;column name="START_DATE"/&gt;
            &lt;column name="END_DATE"/&gt;
        &lt;/property&gt;
        &lt;property name="createDate" not-null="true" column="CREATE_DATE"
            type="com.retek.rpm.domain.calendar.dao.RDateType"/&gt;
        &lt;property name="createID" not-null="true" column="CREATE_ID" type="string"/&gt;
        &lt;property name="approvalDate" not-null="false" column="APPROVAL_DATE"
            type="com.retek.rpm.domain.calendar.dao.RDateType"/&gt;
        &lt;property name="approvalID" not-null="false" column="APPROVAL_ID" type="string"/&gt;
        &lt;property name="stateCode" column="STATE" type="string"/&gt;
        &lt;joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentSimpleDetailImpl"
            table="RPM_PROMO_COMP_SIMPLE" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister"&gt;
            &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
            &lt;property name="merchandiseNode"
                type="com.retek.rpm.domain.promotion.dao.MerchandiseNodeUserType$All"
                access="field"&gt;
                &lt;column name="MERCH_TYPE" not-null="true"/&gt;
                &lt;column name="DEPT" not-null="false"/&gt;
                &lt;column name="CLASS" not-null="false"/&gt;
                &lt;column name="SUBCLASS" not-null="false"/&gt;
                &lt;column name="ITEM" not-null="false"/&gt;
                &lt;column name="DIFF_ID" not-null="false"/&gt;
            &lt;/property&gt;
            &lt;property name="zoneGroupNode"
                type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType" access="field"&gt;
                &lt;column name="ZONE_NODE_TYPE"/&gt;
                &lt;column name="ZONE_ID"/&gt;
                &lt;column name="LOCATION"/&gt;
            &lt;/property&gt;
            &lt;property name="retailChangeValue" access="field"
                type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType"&gt;
                &lt;column name="CHANGE_TYPE" not-null="true"/&gt;
                &lt;column name="CHANGE_AMOUNT" not-null="false"/&gt;
                &lt;column name="CHANGE_CURRENCY" not-null="false"/&gt;
                &lt;column name="CHANGE_PERCENT" not-null="false"/&gt;
                &lt;column name="CHANGE_SELLING_UOM" not-null="false"/&gt;
                &lt;column name="TSL_VOUCHER_NUMBER" not-null="false"/&gt;
                &lt;column name="TSL_VOUCHER_DESC" not-null="false"/&gt;
            &lt;/property&gt;
            &lt;many-to-one name="priceGuide" column="PRICE_GUIDE_ID"
                class="com.retek.rpm.domain.priceguide.bo.PriceGuideImpl" not-null="false"
                access="field"/&gt;
            &lt;property name="attribute1" column="ATTRIBUTE_1" type="string" access="field"/&gt;
            &lt;property name="attribute2" column="ATTRIBUTE_2" type="string" access="field"/&gt;
            &lt;property name="attribute3" column="ATTRIBUTE_3" type="string" access="field"/&gt;
            &lt;many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentSimpleDetailImpl"
                column="EXCEPTION_PARENT_ID" access="field"/&gt;
        &lt;/joined-subclass&gt;
        &lt;joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentThresholdDetailImpl"
            table="RPM_PROMO_COMP_THRESHOLD" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister"&gt;
            &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
            &lt;property name="merchandiseNode"
                type="com.retek.rpm.domain.promotion.dao.MerchandiseNodeUserType$All"
                access="field"&gt;
                &lt;column name="MERCH_TYPE" not-null="true"/&gt;
                &lt;column name="DEPT" not-null="false"/&gt;
                &lt;column name="CLASS" not-null="false"/&gt;
                &lt;column name="SUBCLASS" not-null="false"/&gt;
                &lt;column name="ITEM" not-null="false"/&gt;
                &lt;column name="DIFF_ID" not-null="false"/&gt;
            &lt;/property&gt;
            &lt;property name="zoneGroupNode"
                type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType" access="field" &gt;
                &lt;column name="ZONE_NODE_TYPE"/&gt;
                &lt;column name="ZONE_ID"/&gt;
                &lt;column name="LOCATION"/&gt;
            &lt;/property&gt;
            &lt;many-to-one name="threshold" column="THRESHOLD_ID"
                class="com.retek.rpm.domain.promotion.bo.ThresholdImpl" not-null="true"
                access="field"/&gt;
            &lt;property name="attribute1" column="ATTRIBUTE_1" type="string" access="field"/&gt;
            &lt;property name="attribute2" column="ATTRIBUTE_2" type="string" access="field"/&gt;
            &lt;property name="attribute3" column="ATTRIBUTE_3" type="string" access="field"/&gt;
            &lt;property name="isExclusion" column="EXCLUSION" type="boolean" access="field"/&gt;
            &lt;many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentThresholdDetailImpl"
                column="EXCEPTION_PARENT_ID" access="field"/&gt;
        &lt;/joined-subclass&gt;
        &lt;joined-subclass
            name="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"
            table="RPM_PROMO_COMP_BUY_GET" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister"&gt;
            &lt;meta attribute="lazy-load-collection"&gt;zoneGroupNodes&lt;/meta&gt;
            &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
            &lt;property name="all" column="BUY_ITEM_TYPE" type="boolean" not-null="true"/&gt;
            &lt;property name="buyQuantity" column="BUY_ITEM_QTY"
                type="com.retek.rpm.domain.promotion.dao.QuantityUserType" not-null="true"/&gt;
            &lt;property name="retailChangeValue" access="field"
                type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType"&gt;
                &lt;column name="CHANGE_TYPE" not-null="true"/&gt;
                &lt;column name="CHANGE_AMOUNT" not-null="false"/&gt;
                &lt;column name="CHANGE_CURRENCY" not-null="false"/&gt;
                &lt;column name="CHANGE_PERCENT" not-null="false"/&gt;
                &lt;column name="CHANGE_SELLING_UOM" not-null="false"/&gt;
                &lt;column name="TSL_VOUCHER_NUMBER" not-null="false"/&gt;
                &lt;column name="TSL_VOUCHER_DESC" not-null="false"/&gt;
            &lt;/property&gt;
            &lt;set name="buyItems" access="field" table="RPM_PROMO_BUY_ITEM" inverse="false"
                lazy="true" cascade="none" persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/&gt;
                &lt;many-to-many class="com.retek.rpm.domain.core.bo.ItemImpl" column="ITEM"/&gt;
            &lt;/set&gt;
            &lt;set name="getItems" access="field" table="RPM_PROMO_GET_ITEM" inverse="false"
                lazy="true" cascade="none" persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/&gt;
                &lt;many-to-many class="com.retek.rpm.domain.core.bo.ItemImpl" column="ITEM"/&gt;
            &lt;/set&gt;
            &lt;set name="zoneGroupNodes" access="field" table="RPM_PROMO_BUY_GET_ZONE"
                inverse="false" lazy="false" cascade="none"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
                &lt;element type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType"&gt;
                    &lt;column name="ZONE_NODE_TYPE" sql-type="long"/&gt;
                    &lt;column name="ZONE_ID" sql-type="long"/&gt;
                    &lt;column name="LOCATION" sql-type="long"/&gt;
                &lt;/element&gt;
            &lt;/set&gt;
            &lt;set name="promotionComponentDetailLocationExclusions" cascade="save-update"
                access="field" inverse="false" lazy="true"&gt;
                &lt;key column="EXCLUSION_PARENT_ID"/&gt;
                &lt;one-to-many
                    class="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"/&gt;
            &lt;/set&gt;
            &lt;many-to-one name="parentPromotionComponentDetail"
                class="com.retek.rpm.domain.promotion.bo.PromotionComponentBuyGetDetailImpl"
                column="EXCLUSION_PARENT_ID" access="field"/&gt;
        &lt;/joined-subclass&gt;

        &lt;!--Changes for Mod 93 --&gt;
        &lt;joined-subclass                       
            name="com.retek.rpm.domain.promotion.bo.TslPromotionComponentMultiBuyDetailImpl"
            table="TSL_RPM_PROMO_COMP_M_B" dynamic-update="true"
            persister="com.retek.rpm.domain.core.dao.RetekNormalizedEntityPersister"&gt;
              &lt;meta attribute="lazy-load-collection"&gt;zoneGroupNodes&lt;/meta&gt;
         &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
                                       
            &lt;property name="multiBuyPromotionType" column="MULTI_BUY_PROMO_TYPE" type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyTypeStringCodeConverter" not-null="true"/&gt;
            &lt;!-- coupon to be included --&gt;
         
         
            &lt;set name="listDetails" inverse="true" lazy="true" cascade="all"&gt;
            &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
            &lt;one-to-many class="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl"/&gt;
         &lt;/set&gt;         
                  
         &lt;!--                                
            &lt;set name="listDetails" table="TSL_RPM_PROMO_COMP_M_B_DTL" persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister" access="field" inverse="true" lazy="true"&gt;
         &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
         &lt;one-to-many class="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl"/&gt;
         &lt;column name="LIST_ID" not-null="true"/&gt;
         &lt;column name="LIST_TYPE" not-null="false"/&gt;
         &lt;column name="BUY_ITEM_TYPE" not-null="false"/&gt;         
         &lt;column name="BUY_ITEM_VALUE" not-null="false"/&gt;            
         &lt;column name="CHANGE_TYPE" not-null="false"/&gt;
          &lt;column name="CHANGE_AMOUNT" not-null="false"/&gt;
          &lt;column name="CHANGE_CURRENCY" not-null="false"/&gt;
          &lt;column name="CHANGE_PERCENT" not-null="false"/&gt;
          &lt;column name="CHANGE_SELLING_UOM" not-null="false"/&gt;
          &lt;column name="VOUCHER_NUMBER" not-null="false"/&gt;
          &lt;column name="VOUCHER_DESCRIPTION" not-null="false"/&gt;   
          &lt;column name="LOCK_VERSION" not-null="false"/&gt;   
          &lt;column name="GET_QUANTITY" not-null="false"/&gt;                       
          &lt;/many-to-many&gt;                
          &lt;/set&gt;
          --&gt;
         &lt;!--                                                                         
              &lt;set name="listDetails" table="TSL_RPM_PROMO_COMP_M_B_DTL" inverse="true"
                persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister" cascade="save-update"&gt;
            &lt;key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/&gt;                                               
                &lt;composite-element class="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl"&gt;   
                    &lt;property name="displayId" column="LIST_ID" type="string"/&gt;                                 
                   &lt;property name="listTypes" column="LIST_TYPE"  type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyListTypeCodeConverter"/&gt;
               &lt;property name="buyListType" column="BUY_ITEM_TYPE" type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyPromotionBuyTypeCodeConverter"/&gt;
                   &lt;property name="value" column="BUY_ITEM_VALUE"/&gt;
                   &lt;property name="retailChangeValue" access="field"
                      type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType" not-null="false"&gt;
                        &lt;column name="CHANGE_TYPE" not-null="false"/&gt;
                      &lt;column name="CHANGE_AMOUNT" not-null="false"/&gt;
                      &lt;column name="CHANGE_CURRENCY" not-null="false"/&gt;
                      &lt;column name="CHANGE_PERCENT" not-null="false"/&gt;
                      &lt;column name="CHANGE_SELLING_UOM" not-null="false"/&gt;
                      &lt;column name="VOUCHER_NUMBER" not-null="false"/&gt;
                      &lt;column name="VOUCHER_DESCRIPTION" not-null="false"/&gt;
                 &lt;/property&gt;                
                 &lt;property name="lockVersion" column="LOCK_VERSION" not-null="false"/&gt;
              &lt;property name="getQuantity" column="GET_QUANTITY" type="com.retek.rpm.domain.promotion.dao.QuantityUserType" not-null="false"/&gt;                                  
                &lt;/composite-element&gt;
                &lt;/set&gt;               
               --&gt;                 
               &lt;!--                 
                &lt;set name="buyListItems" table="TSL_RPM_PROMO_BUY_ITEM"
                persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/&gt;               
                &lt;composite-element class="com.retek.rpm.domain.promotion.bo.TslBuyItemImpl"&gt;   
                    &lt;property name="listDisplayId" column="LIST_ID"/&gt;                                 
                   &lt;property name="item" column="ITEM"/&gt;
               &lt;property name="dept" column="DEPT"/&gt;
                   &lt;property name="classId" column="CLASS"/&gt;
                   &lt;property name="subclass" column="SUBCLASS"/&gt;
                   &lt;property name="merchType" column="MERCH_TYPE"/&gt;                                            
                   &lt;property name="diffId" column="DIFF_ID"/&gt;                  
                &lt;/composite-element&gt;
                &lt;/set&gt;               
                --&gt;
               
                &lt;!--               
                &lt;set name="getListItems" table="TSL_RPM_PROMO_GET_ITEM"
                persister="com.retek.rpm.domain.core.dao.RetekBasicCollectionPersister"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID" foreign-key="RPM_PROMO_COMP_DETAIL_ID"/&gt;               
                &lt;composite-element class="com.retek.rpm.domain.promotion.bo.TslGetItemImpl"&gt;   
                    &lt;property name="listDisplayId" column="LIST_ID"/&gt;                                 
                   &lt;property name="item" column="ITEM"/&gt;
               &lt;property name="dept" column="DEPT"/&gt;
                   &lt;property name="classId" column="CLASS"/&gt;
                   &lt;property name="subclass" column="SUBCLASS"/&gt;
                   &lt;property name="merchType" column="MERCH_TYPE"/&gt;                                            
                   &lt;property name="diffId" column="DIFF_ID"/&gt;                  
                &lt;/composite-element&gt;
                &lt;/set&gt;
                --&gt;
           &lt;!--                             
           &lt;set name="zoneGroupNodes" access="field" table="TSL_RPM_PROMO_MULTI_BUY_ZONE"
                inverse="false" lazy="false" cascade="none"&gt;
                &lt;key column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
                &lt;element type="com.retek.rpm.domain.promotion.dao.ZoneGroupNodeUserType"&gt;
                    &lt;column name="ZONE_NODE_TYPE" sql-type="long"/&gt;
                    &lt;column name="ZONE_ID" sql-type="long"/&gt;
                    &lt;column name="LOCATION" sql-type="long"/&gt;
                &lt;/element&gt;
            &lt;/set&gt;
            --&gt;
            &lt;!--
            &lt;set name="promotionComponentDetailLocationExclusions" cascade="save-update"
                access="field" inverse="false" lazy="true"&gt;
                &lt;key column="EXCLUSION_PARENT_ID"/&gt;
                &lt;one-to-many
                    class="com.retek.rpm.domain.promotion.bo.TslPromotionComponentMultiBuyDetailImpl"/&gt;
            &lt;/set&gt;
            --&gt;
         &lt;/joined-subclass&gt;
    &lt;/class&gt;
&lt;/hibernate-mapping&gt;


Code:
   
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"&gt;

&lt;!--
     modified by: Lakshmi Natarajan - LN,lakshmi.natarajan@in.tesco.com
     date: 26-April-2007 v1.0
     Mod ref: 365a
     Mod Description: Addition of new properties sTslBaseItem,bTslPriceMarkInd and bTslPrimPackInd corresponding to
                      ITEM_MASTER.TSL_BASE_ITEM,ITEM_MASTER.TSL_PRICE_MARK_IND and ITEM_MASTER.TSL_PRIM_PACK_IND
--&gt;
       
&lt;hibernate-mapping&gt;
       &lt;class name="com.retek.rpm.domain.promotion.bo.TslMultiBuyListImpl" table="TSL_RPM_PROMO_COMP_M_B_DTL"&gt;         
              &lt;composite-id unsaved-value="any"&gt;
                  &lt;key-property name="displayId" type="java.lang.String" column="LIST_ID"/&gt;
                  &lt;key-many-to-one name="tslPromotionComponentMultiBuyDetailImpl" class="com.retek.rpm.domain.promotion.bo.TslPromotionComponentMultiBuyDetailImpl" column="RPM_PROMO_COMP_DETAIL_ID"/&gt;
              &lt;/composite-id&gt;
              &lt;property name="listTypes" column="LIST_TYPE"  type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyListTypeCodeConverter" insert="false" update="false" access="field"/&gt;
            &lt;property name="buyListType" column="BUY_ITEM_TYPE" type="com.retek.rpm.domain.core.dao.codeconverter.TslMultiBuyPromotionBuyTypeCodeConverter" insert="false" update="false" access="field"/&gt;
            &lt;property name="value" column="BUY_ITEM_VALUE" insert="false" update="false" access="field"/&gt;
            &lt;property name="retailChangeValue" access="field"
               type="com.retek.rpm.domain.promotion.dao.RetailChangeValueUserType" insert="false" update="false"&gt;
               &lt;column name="CHANGE_TYPE" not-null="false"/&gt;
               &lt;column name="CHANGE_AMOUNT" not-null="false"/&gt;
               &lt;column name="CHANGE_CURRENCY" not-null="false"/&gt;
               &lt;column name="CHANGE_PERCENT" not-null="false"/&gt;
               &lt;column name="CHANGE_SELLING_UOM" not-null="false"/&gt;
               &lt;column name="VOUCHER_NUMBER" not-null="false"/&gt;
               &lt;column name="VOUCHER_DESCRIPTION" not-null="false"/&gt;
              &lt;/property&gt;
               &lt;property name="lockVersion" column="LOCK_VERSION" not-null="false" insert="false" update="false" access="field"/&gt;
               &lt;property name="getQuantity" column="GET_QUANTITY" type="com.retek.rpm.domain.promotion.dao.QuantityUserType" not-null="false" insert="false" update="false" access="field"/&gt;
         &lt;/class&gt;         
&lt;/hibernate-mapping&gt;


I also had to set the class from the second hbm file implementing Serializable.

Many Thanks
Rui Felix


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.