-->
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.  [ 5 posts ] 
Author Message
 Post subject: Returned collection has first element only on all elements
PostPosted: Mon Sep 04, 2006 11:55 pm 
Newbie

Joined: Mon Sep 04, 2006 11:41 pm
Posts: 3
Hello. Whenever I query for a collection, the collection returned would be sized correctly but all elements would all have the value of the first element. In my case, I have a MealOrder that has a bag of SpecialMeals. Whenever I try to get a collection of SpecialMeals, the first element of the resultset repeats on all the elements of the collection. If I am supposed to get 80 SpecialMeals, for example, I'll get 80 all right but the other 79 after the first SpecialMeal in the collection are the same as the first SpecialMeal. I have the mappings and query pertaining to retrieving the collection below.

Mappings:

MealOrder

Code:

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

<hibernate-mapping>
   <class
      name="com.air.crew.kitchen.biz.domain.mealorder.MealOrder"
      schema="DB2CAT"
      table="T_MEAL_ORD">

      <composite-id>
              <key-property name="airlineCode" column="AL_CDE" type="string"/>
              <key-property name="localDepartureDate" column="LCL_DPTR_DTE" type="date"/>                 
              <key-property name="origin" column="MEAL_ORIG_AP_CDE" type="string"/>             
              <key-property name="flightNumber" column="MEAL_FLT_NUM" type="string"/>                               
              <key-property name="mealOrderCode" column="MEAL_ORD_CDE" type="string"/>
      </composite-id>      
   
      <property
           name="status"
            column="MEAL_PRDCT_CDE"
            type="string"/>           
      <!--
      <property
           name="market"
            column="FLT_MKT"
            type="character"/>   
      -->   
               
      <component
         name="boarding"
         class="com.air.crew.kitchen.biz.domain.mealorder.BoardingInformation">
         
         <property
            name="flightNumber"            
            column="MEAL_BRDG_FLT_NUM"
            type="string"/>
         <property
            name="flightDate"            
            column="MEAL_BRDG_LCL_DTE"
            type="date"/>         
         <property
            name="flightTime"            
            column="MEAL_BRDG_LCL_TME"
            type="time"/>      
      </component>
            
      <component
         name="serving"
         class="com.air.crew.kitchen.biz.domain.mealorder.ServingInformation">
         <!--
         <property
            name="origin"            
            column="MEAL_ORIG_AP_CDE"
            type="string"/>
         -->
         
         <property
            name="destination"            
            column="MEAL_DEST_AP_CDE"
            type="string"/>      
         <!--   
         <property
            name="flightNumber"            
            column="MEAL_FLT_NUM"
            type="string"/>   
         -->
         <property
            name="equipment"            
            column="EQP_TYP_CDE"
            type="string"/>      
      </component>
      
      <component
         name="crewMeal"
         class="com.air.crew.kitchen.biz.domain.mealorder.CrewMeal">
         
         <property
            name="pilotCount"            
            column="CKPT_CRW_CNT"
            type="integer"/>
         <property
            name="domesticFACount"            
            column="CBN_CRW_CNT"
            type="integer"/>   
         <!--         
         <property
            name="pacificFACount"            
            type="short"
            column="CBN_CREW_CNT"/>   
         -->
      </component>   
         
      <bag name="cabinMeals">
         <key>
            <column name="AL_CDE"/>
            <column name="LCL_DPTR_DTE"/>
            <column name="MEAL_ORIG_AP_CDE"/>
            <column name="MEAL_FLT_NUM"/>
            <column name="CBN_CL_CDE"/>         
         </key>
         <one-to-many class="com.air.crew.kitchen.biz.domain.mealorder.CabinMeals"/>
      </bag>   
               
      <bag name="specialMeals">
         <key>
            <column name="AL_CDE"/>
            <column name="LCL_DPTR_DTE"/>
            <column name="MEAL_ORIG_AP_CDE"/>
            <column name="MEAL_FLT_NUM"/>
            <column name="CBN_CL_CDE"/>
         </key>
         <one-to-many class="com.air.crew.kitchen.biz.domain.mealorder.SpecialMeals"/>
      </bag>           
                 
   </class>
   
</hibernate-mapping>



SpecialMeals

Code:

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

<hibernate-mapping>
   
   <class name="com.air.crew.kitchen.biz.domain.mealorder.SpecialMeals"
         schema="DB2CAT"
         table="T_CBN_SPEC_MEAL">
      <composite-id>
              <key-property name="airlineCode" column="AL_CDE" type="string"/>
              <key-property name="localDepartureDate" column="LCL_DPTR_DTE" type="date"/>             
              <key-property name="originAPCode" column="MEAL_ORIG_AP_CDE" type="string"/>             
              <key-property name="flightNumber" column="MEAL_FLT_NUM" type="string"/>          
              <key-property name="cabinClassCode" column="CBN_CL_CDE" type="string"/>
      </composite-id>          
      <property
           name="mealCode"
            column="SPEC_MEAL_CDE"
            type="string"/>   
      <property
           name="mealCount"
            column="SPEC_MEAL_CNT"
            type="integer"/>
      <property
           name="mealDesc"
            column="SPEC_MEAL_DESC"
            type="string"/>              
    </class>
      
</hibernate-mapping>



The query retrieving the SpecialMeals collection

Code:
select specialmea0_.AL_CDE as AL1_1_, specialmea0_.LCL_DPTR_DTE as LCL2_1_, specialmea0_.MEAL_ORIG_AP_CDE as MEAL3_1_, specialmea0_.MEAL_FLT_NUM as MEAL4_1_, specialmea0_.CBN_CL_CDE as CBN5_1_, specialmea0_.AL_CDE as AL1_3_0_, specialmea0_.LCL_DPTR_DTE as LCL2_3_0_, specialmea0_.MEAL_ORIG_AP_CDE as MEAL3_3_0_, specialmea0_.MEAL_FLT_NUM as MEAL4_3_0_, specialmea0_.CBN_CL_CDE as CBN5_3_0_, specialmea0_.SPEC_MEAL_CDE as SPEC6_3_0_, specialmea0_.SPEC_MEAL_CNT as SPEC7_3_0_, specialmea0_.SPEC_MEAL_DESC as SPEC8_3_0_ from DB2CAT.T_CBN_SPEC_MEAL specialmea0_ where specialmea0_.AL_CDE=? and specialmea0_.LCL_DPTR_DTE=? and specialmea0_.MEAL_ORIG_AP_CDE=? and specialmea0_.MEAL_FLT_NUM=? and specialmea0_.CBN_CL_CDE=?


Last edited by nikkfurie on Tue Sep 05, 2006 1:28 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: RE:Returned collection has first element only on all elem...
PostPosted: Tue Sep 05, 2006 2:38 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
Please post your query, otherwise we can't help you.

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
 Post subject: Complete details of what I am working on
PostPosted: Tue Sep 05, 2006 3:30 am 
Newbie

Joined: Mon Sep 04, 2006 11:41 pm
Posts: 3
moved contents of the message to my first post.


Last edited by nikkfurie on Tue Sep 05, 2006 1:29 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: RE:Complete details of what I am working on
PostPosted: Tue Sep 05, 2006 7:22 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
The only thing that catched my eye is a missing "inverse" property set to true in your "bag" tags. I'm not sure whether this is the reason for getting 80 times the same SpecialMeal, but give it a try.

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
 Post subject: Re: RE:Complete details of what I am working on
PostPosted: Tue Sep 05, 2006 12:10 pm 
Newbie

Joined: Mon Sep 04, 2006 11:41 pm
Posts: 3
gskempes wrote:
The only thing that catched my eye is a missing "inverse" property set to true in your "bag" tags. I'm not sure whether this is the reason for getting 80 times the same SpecialMeal, but give it a try.


Setting the inverse attribute of the collections to true isn't necessary as MealOrder is uni-directonally mapped to SpecialMeals, not bi-directional.

Any other ideas, guys? :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.