-->
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: Merge a component from 2 different join
PostPosted: Thu Jul 28, 2011 5:42 pm 
Newbie

Joined: Fri Jul 22, 2011 10:04 am
Posts: 3
Hello guys,

I have the following problem, CustomerVoucherAgreementImpl.class (table="E_VOUCHER_CUST_AGREEMENT") has a shared component(orderRelatedData) with his child CustomerVoucherAgreementImplCL.class (table="E_VOUCHER_CUST_AGREEMENT_CL"), and when I try to read a CustomerVoucherAgreementImplCL.class(the select statement is correctly executed and brings all the requested values), the orderRelatedData component sets to null the attributes filled by first join(E_VOUCHER_CUST_AGREEMENT).
The question is, How can I merge a component from 2 tables?.

E_VOUCHER_CUST_AGREEMENT table (CustomerVoucherAgreementImpl.class)
Code:
<hibernate-mapping>
   <subclass name="CustomerVoucherAgreementImpl" extends="BaseCustomerAgreement" lazy="false" >
      <join table="E_VOUCHER_CUST_AGREEMENT">
         <key column="AGREEMENT_ID" not-null="true" unique="true"/>
         <component name="orderRelatedData" class="CustomerAgreementOrderRelatedDataCL" lazy="false">
            <property name="rememberOrderMonthDay" column="N_REMEMBERORDERMONTH_DAY" type="integer" />
            <property name="maximumOrderRequestMonthDay" column="N_MAXREQUESTORDERMONTHDAY" type="integer" />
            <property name="maximumOrderDeliveryMonthDay" column="N_MAX_DELIVERORDERMONTHDAY" type="integer" />
            <property name="lastPersonalizedOrder" column="D_LASTPERSONALIZEDORDER" type="date" />
            <property name="lastNotPersonalizedOrder" column="D_LASTNOTPERSONALIZEDORDER" type="date" />
         </component>
         <component name="physicalSupportSpecification" class="PhysicalSupportSpecificationCL" lazy="false">
             <property name="mediaSupportTypes" column="VSMEDIAPHYSICALSUPPORTTYPE_ID" type="long" not-null="true" />
             <property name="validityPeriodTypeSpecification" column="VALPERIODTPSPECIF_ID" type="long" />
         </component>
         <property name="deliveryStructure" column="DELIVERYNODE_ID" type="long" />   
         <component name="packagingSpecification" class="CustomerAgreementPackagingSpecification" lazy="false">
            <property name="containerStructure" column="STRUCTURE_ID" type="long" />
         </component>
      </join>
   </subclass>
</hibernate-mapping>


E_VOUCHER_CUST_AGREEMENT_CL table (CustomerVoucherAgreementImplCL.class)
Code:
<hibernate-mapping>
   <subclass name="CustomerVoucherAgreementImplCL" extends="CustomerVoucherAgreementImpl" lazy="false" >
      <meta attribute="orderRelatedData" inherit="true" />
      <meta attribute="physicalSupportSpecification" inherit="true" />
      <join table="E_VOUCHER_CUST_AGREEMENT_CL" inverse="true">
         <key column="AGREEMENT_ID"/>
         <component name="orderRelatedData" class="CustomerAgreementOrderRelatedDataCL" lazy="false">
            <property name="deliverFormOrder" column="B_DELIVERFORM" type="true_false" />
            <property name="sendBeneficiaryList" column="B_SENDBENEFICIARYLIST" type="true_false" />
            <property name="loadOrderByNodeCode" column="B_LOADORDERBYNODECODE" type="true_false" />
            <property name="loadExtendedOrder" column="B_LOADEXTENDEDORDER" type="true_false" />
            <component name="automaticOrderGenerationSpecification" class="AutomaticOrderGenerationSpecificationCL" lazy="false">
               <property name="automaticGenerationDay" column="Q_AUTOMATICGENERATIONDAY" type="integer"></property>
               <property name="automaticGeneration" column="B_AUTOMATICORDERGENERATION" type="true_false"></property>
            </component>
         </component>
         <component name="physicalSupportSpecification" class="PhysicalSupportSpecificationCL" lazy="false">
            <property name="beneficiaryExpirationTypes" column="VSBENEFICIARYEXPIRATIONTYPE_ID" type="long" />
            <property name="consumptionDays" column="Q_CONSUMPTIONSDAYS" type="integer" />
            <property name="noBeneficiaryExpirationTypes" column="VSNOBENEFICIARYEXPTYPE_ID" type="long" />
            <property name="qtyOfMonthBeforeConsumption" column="Q_MONTHFORCREATEBEFORECONSUMPT" type="integer" />
         </component>
      </join>
   </subclass>
</hibernate-mapping>


CustomerAgreementOrderRelatedData.class

Code:
import java.util.Date;

public class CustomerAgreementOrderRelatedData {

    protected Integer rememberOrderMonthDay;       
    protected Integer maximumOrderRequestMonthDay;    
    protected Integer maximumOrderDeliveryMonthDay;   
    protected Date lastPersonalizedOrder;            
    protected Date lastNotPersonalizedOrder;         

    protected CustomerAgreementOrderRelatedData() { }

    public Date getLastNotPersonalizedOrder() {
        return this.lastNotPersonalizedOrder;
    }

    public void setLastNotPersonalizedOrder(Date lastNotPersonalizedOrder) {
        this.lastNotPersonalizedOrder = lastNotPersonalizedOrder;
    }

    public Date getLastPersonalizedOrder() {
        return this.lastPersonalizedOrder;
    }

    public void setLastPersonalizedOrder(Date lastPersonalizedOrder) {
        this.lastPersonalizedOrder = lastPersonalizedOrder;
    }

    public Integer getMaximumOrderDeliveryMonthDay() {
        return this.maximumOrderDeliveryMonthDay;
    }

    public void setMaximumOrderDeliveryMonthDay(Integer maximumOrderDeliveryMonthDay) {
        this.maximumOrderDeliveryMonthDay = maximumOrderDeliveryMonthDay;
    }

    public Integer getMaximumOrderRequestMonthDay() {
        return this.maximumOrderRequestMonthDay;
    }

    public void setMaximumOrderRequestMonthDay(Integer maximumOrderRequestMonthDay) {
        this.maximumOrderRequestMonthDay = maximumOrderRequestMonthDay;
    }

    public Integer getRememberOrderMonthDay() {
        return this.rememberOrderMonthDay;
    }
   
    public void setRememberOrderMonthDay(Integer rememberOrderMonthDay) {
        this.rememberOrderMonthDay = rememberOrderMonthDay;
    }
}


CustomerAgreementOrderRelatedDataCL.class
Code:

public class CustomerAgreementOrderRelatedDataCL extends CustomerAgreementOrderRelatedData {

    private Boolean deliverFormOrder;            
    private Boolean sendBeneficiaryList;          
    private Boolean loadOrderByNodeCode;
    private Boolean loadExtendedOrder;
    private AutomaticOrderGenerationSpecificationCL automaticOrderGenerationSpecification;
   
    protected CustomerAgreementOrderRelatedDataCL() {
       super();
    }

    public Boolean getDeliverFormOrder() {
        return this.deliverFormOrder;
    }

    public void setDeliverFormOrder(Boolean deliverFormOrder) {
        this.deliverFormOrder = deliverFormOrder;
    }
   
    public Boolean getSendBeneficiaryList() {
        return this.sendBeneficiaryList;
    }

    public void setSendBeneficiaryList(Boolean sendBeneficiaryList) {
        this.sendBeneficiaryList = sendBeneficiaryList;
    }

    public Boolean getLoadOrderByNodeCode() {
        return this.loadOrderByNodeCode;
    }

    public void setLoadOrderByNodeCode(Boolean loadOrderByNodeCode) {
        this.loadOrderByNodeCode = loadOrderByNodeCode;
    }
   
    public Boolean getLoadExtendedOrder() {
        if (this.loadExtendedOrder == null){
            return Boolean.FALSE;
        }
        return this.loadExtendedOrder;
    }

    public void setLoadExtendedOrder(Boolean loadExtendedOrder) {
        this.loadExtendedOrder = loadExtendedOrder;
    }
   
    public AutomaticOrderGenerationSpecificationCL getAutomaticOrderGenerationSpecification() {
        return this.automaticOrderGenerationSpecification;
    }

    public void setAutomaticOrderGenerationSpecification(AutomaticOrderGenerationSpecificationCL automaticOrderGenerationSpecification) {
        this.automaticOrderGenerationSpecification = automaticOrderGenerationSpecification;
    }   
}


Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Merge a component from 2 different join
PostPosted: Tue Aug 02, 2011 3:38 pm 
Newbie

Joined: Fri Jul 22, 2011 10:04 am
Posts: 3
I have found a really ugly way...

This case can be resolved by "formula", so, we have to concat the original alias and the column name.
Quote:
<property name="maximumOrderRequestMonthDay" column="N_MAXREQUESTORDERMONTHDAY" type="integer" formula="customervo0_2_.N_MAXREQUESTORDERMONTHDAY" />


E_VOUCHER_CUST_AGREEMENT_CL table (CustomerVoucherAgreementImplCL.class)
Code:
<hibernate-mapping>
   <subclass name="CustomerVoucherAgreementImplCL" extends="CustomerVoucherAgreementImpl">
      <join table="E_VOUCHER_CUST_AGREEMENT_CL">
         <key column="AGREEMENT_ID"/>
         <component name="orderRelatedData" class="CustomerAgreementOrderRelatedDataCL">
                                                <!-- E_VOUCHER_CUST_AGREEMENT -->
            <property name="maximumOrderRequestMonthDay" column="N_MAXREQUESTORDERMONTHDAY" type="integer" formula="customervo0_2_.N_MAXREQUESTORDERMONTHDAY" />
            <property name="maximumOrderDeliveryMonthDay" column="N_MAX_DELIVERORDERMONTHDAY" type="integer" formula="customervo0_2_.N_MAX_DELIVERORDERMONTHDAY" />
            <property name="lastPersonalizedOrder" column="D_LASTPERSONALIZEDORDER" type="date" formula="customervo0_2_.D_LASTPERSONALIZEDORDER" />
            <property name="lastNotPersonalizedOrder" column="D_LASTNOTPERSONALIZEDORDER" type="date" formula="customervo0_2_.D_LASTNOTPERSONALIZEDORDER" />
            <property name="rememberOrderMonthDay" column="N_REMEMBERORDERMONTH_DAY" type="integer" formula="customervo0_2_.N_REMEMBERORDERMONTH_DAY" />
                                                <!-- E_VOUCHER_CUST_AGREEMENT_CL -->
            <property name="deliverFormOrder" column="B_DELIVERFORM" type="true_false" />
            <property name="sendBeneficiaryList" column="B_SENDBENEFICIARYLIST" type="true_false" />
            <property name="loadOrderByNodeCode" column="B_LOADORDERBYNODECODE" type="true_false" />
            <property name="loadExtendedOrder" column="B_LOADEXTENDEDORDER" type="true_false" />
            <component name="automaticOrderGenerationSpecification" class="AutomaticOrderGenerationSpecificationCL">
               <property name="automaticGenerationDay" column="Q_AUTOMATICGENERATIONDAY" type="integer"></property>
               <property name="automaticGeneration" column="B_AUTOMATICORDERGENERATION" type="true_false"></property>
            </component>
         </component>
         <component name="physicalSupportSpecification" class="PhysicalSupportSpecificationCL">
                                                <!-- E_VOUCHER_CUST_AGREEMENT -->
            <property name="mediaSupportTypes" column="VSMEDIAPHYSICALSUPPORTTYPE_ID" type="long" not-null="true" formula="customervo0_2_.VSMEDIAPHYSICALSUPPORTTYPE_ID" />
             <property name="validityPeriodTypeSpecification" column="VALPERIODTPSPECIF_ID" type="long" formula="customervo0_2_.VALPERIODTPSPECIF_ID" />
                                                 <!-- E_VOUCHER_CUST_AGREEMENT_CL -->
            <property name="beneficiaryExpirationTypes" column="VSBENEFICIARYEXPIRATIONTYPE_ID" type="long" />
            <property name="consumptionDays" column="Q_CONSUMPTIONSDAYS" type="integer" />
            <property name="noBeneficiaryExpirationTypes" column="VSNOBENEFICIARYEXPTYPE_ID" type="long" />
            <property name="qtyOfMonthBeforeConsumption" column="Q_MONTHFORCREATEBEFORECONSUMPT" type="integer" />
         </component>
      </join>
   </subclass>
</hibernate-mapping>


Now we need to know if is it possible to define a static alias, when we define a table, for example, inside of a join element, obviously I saw the DTD and isn't possible, but maybe there is another way that you want to share with us. We know that the alias is defined by "Hibernate" and that's why we want to get the control of it.

Thanks in advance.


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.