-->
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: Outer join doesn't work
PostPosted: Mon Sep 03, 2007 4:47 am 
Newbie

Joined: Wed Nov 02, 2005 6:07 am
Posts: 12
Hibernate version:3

Hi,

I'm using the following statement:


Code:
        Criteria crit = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(DeliveryLineRim.class)
            .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
            .add(Expression.eq("bpCd", data.getBpCd()))
            .add(Expression.eq("bpOdsCd", data.getBpOdsCd()))
            .setFetchMode("groupTypeCode", FetchMode.JOIN)
            .createAlias("groupTypeCode", "groupTypeCode")           
            .add(Expression.eq("groupTypeCode.grpTyCd", "CUSX1"))
            .addOrder(Order.asc("dlvyNo"))
            .addOrder(Order.asc("dlvyLiNo"));


These are my mapping files:

Code:
<hibernate-mapping package="de.arvatologistics.rim.model">
    <class name="DeliveryLineRim" table="c_d_li_rim_s2">

        <composite-id>
            <key-property name="dlvyLiNo" type="java.lang.Integer" column="dlvy_li_no" />
            <key-property name="dlvyNo" type="java.lang.Integer" column="dlvy_no" />
      </composite-id>

      <properties name="key">
         <property name="BpCd" column="bp_cd" insert="false" update="false" />
         <property name="BpOdsCd" column="bp_ods_cd" insert="false" update="false"/>
         <property name="CustNb" column="cust_nb" insert="false" update="false"/>
      </properties>      

         <property name="BOReaCd" type="java.lang.String">
             <column name="b_o_rea_cd" length="1" />
         </property>
         <property name="bpCd" type="java.lang.String">
             <column name="bp_cd" length="5" />
         </property>
         <property name="bpCustNb" type="java.lang.String">
             <column name="bp_cust_nb" length="15" />
         </property>
         <property name="bpOdsCd" type="java.lang.String">
             <column name="bp_ods_cd" length="5" />
         </property>
         <property name="catItCd" type="java.lang.String">
             <column name="cat_it_cd" length="20" />
         </property>
         <property name="custNb" type="java.lang.String">
             <column name="cust_nb" length="15" />
         </property>         
         <property name="custNm" type="java.lang.String">
             <column name="cust_nm" length="30" />
         </property>
         <property name="debQ" type="java.lang.Integer">
             <column name="deb_q" />
         </property>
         <property name="diffQ" type="java.lang.Integer">
             <column name="diff_q" />
         </property>
         <property name="disFl" type="java.lang.Short">
             <column name="dis_fl" />
         </property>
         <property name="dlvyDt" type="java.util.Date">
             <column name="dlvy_dt" length="23" />
         </property>
         <property name="dlvyNtRmk" type="java.lang.String">
             <column name="dlvy_nt_rmk" length="100" />
         </property>

      <set name="groupTypeCode">
            <key property-ref="key" update="false">
               <column name="bp_cd"/>
               <column name="bp_ods_cd"/>
               <column name="cust_nb"/>
            </key>
         <one-to-many class="GroupTypeCode"/>
      </set>           
    </class>
</hibernate-mapping>


Code:
<hibernate-mapping package="de.arvatologistics.rim.model">
    <class name="GroupTypeCode" table="c_c_bp_gr2_v2">

        <composite-id>
            <key-property name="bpCd" type="java.lang.String">
                <column name="bp_cd" length="5" />
            </key-property>
            <key-property name="bpOdsCd" type="java.lang.String">
                <column name="bp_ods_cd" length="5" />
            </key-property>
            <key-property name="custNb" type="java.lang.String">
                <column name="cust_nb" length="15" />
            </key-property>
           <key-property name="grpCd" type="java.lang.String">
               <column name="grp_cd" length="5" />
           </key-property>
           <key-property name="grpTyCd" type="java.lang.String">
               <column name="grp_ty_cd" length="5" />
           </key-property>             
        </composite-id>
                             
        <property name="CUid" type="java.lang.String">
            <column name="c_uid" length="10" />
        </property>
        <property name="CDt" type="java.util.Date">
            <column name="c_dt" length="23" />
        </property>
        <property name="UUid" type="java.lang.String">
            <column name="u_uid" length="10" />
        </property>
        <property name="UDt" type="java.util.Date">
            <column name="u_dt" length="23" />
        </property>
        <property name="susyTxCd" type="java.lang.String">
            <column name="susy_tx_cd" length="16" />
        </property>
        <property name="recStat" type="java.lang.Short">
            <column name="rec_stat" />
        </property>

    </class>
</hibernate-mapping>


Unfortunately the groupTypeCode-table will be joined as an inner join. But I need an outer join instead. I thought that FetchMode = JOIN will result in an outer join. Can someone please help me?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 11:59 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
.createAlias("groupTypeCode", "groupTypeCode", Criteria.LEFT_JOIN)

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


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.