-->
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.  [ 1 post ] 
Author Message
 Post subject: Fetching the Collections present in Component using HQL
PostPosted: Wed Feb 21, 2007 9:19 am 
Newbie

Joined: Thu Oct 12, 2006 8:17 am
Posts: 3
Hi,

We are having a requirement where we need to fetch a Component present in a domain object and the collections present in Component. we tried it using HQL but we encountered a problem where we are able to retrive the ordinary properties in component but unable to fetch the properties in collections.

Below is my mapping file.

verify the component demographicInformation with collections alternateMemberID etc.


Code:
<hibernate-mapping>
   <class name="com.acs.enterprise.mmis.member.common.domain.Member" dynamic-insert="true" dynamic-update="true"
           table="B_DTL_TB">
      <id column="B_SYS_ID" name="systemID" type="java.lang.Long">
           <generator class="assigned"/>
      </id>      
      <property name="currAltID" column ="B_CURR_ALT_ID" type="java.lang.String" />
      <property name="currAltIDTypeCode" column ="B_CURR_ALT_ID_TY_CD" type="java.lang.String" />
      <property name="addedAuditUserID" column ="G_AUD_ADD_USER_ID" type="java.lang.String" />   
        <property name="addedAuditTimeStamp" column="G_AUD_ADD_TS" type="timestamp"/> 
      <property name="auditUserID" column="G_AUD_USER_ID" type="java.lang.String"/>
        <property name="auditTimeStamp" column="G_AUD_TS" type="timestamp"/>     

      <component name="demographicInformation" class="com.acs.enterprise.mmis.member.common.domain.DemographicInformation" insert="true" update="true">
         <property name="peProviderAltID" column="P_PE_ALT_ID" type="java.lang.String" />   
          <property name="peProviderAltIDTypeCode" column="P_PE_ALT_ID_TY_CD" type="java.lang.String" />
         <property name="phoneticSearchFirstName" column="B_PHNTC_FIRST_NAM" type="java.lang.String" />
         <property name="phoneticSearchLastName" column="B_PHNTC_LAST_NAM" type="java.lang.String" />
         <property name="confidentiality" column="B_CONFID_CD" type="java.lang.String" />
         <property name="dateOfBirth" column="B_DOB_DT" type="java.util.Date" />
         <property name="updateDateOfDeath" column="B_DOD_UPD_DT"  type="java.util.Date" />
         <property name="vip" column="B_VIP_IND" type="java.lang.String" />
         <property name="demoLock" column ="B_DEM_LOCK_CD" type="java.lang.String" />
         <property name="ssnVerification" column="B_SSN_VRFY_CD" type="java.lang.String" />
         <property name="medicareVerification" column ="B_MCARE_VRFY_CD" type="java.lang.String" />
         <property name="department" column="B_DEPT_CD" type="java.lang.String" />
         <property name="gender" column="B_GENDER_CD" type="java.lang.String" />
         <property name="ethinicCode" column="B_ETH_CD" type="java.lang.String" />
         <property name="primaryLanguage" column="B_LANG_CD" type="java.lang.String" />
         <property name="citizenship" column="B_CITIZEN_CD" type="java.lang.String" />
         <property name="livingArrangement" column="B_LV_ARRANGE_CD" type="java.lang.String" />
         <property name="maritalStatus" column="B_MRTL_STAT_CD" type="java.lang.String" />
         <property name="caseFormNumber" column ="B_CASE_FORM_NUM" type="java.lang.String" />
         <property name="dateOfDeath" column="B_DOD_DT"  type="java.util.Date" />
         <property name="dodVerification" column="B_DOD_VRFY_CD" type="java.lang.String" />
         <property name="applicationDate" column="B_APPL_DT" type="java.util.Date" />
         <property name="medicaidCertDate" column="B_CERT_DT" type="java.util.Date" />
         <property name="expectedConfinementDate" column ="B_EXPT_CONFNMT_DT" type="java.util.Date" />
         <property name="tribalAffiliation" column ="B_TRIBAL_AFFL_CD" type="java.lang.String" />
         <property name="familyStatusCode" column ="B_FAM_STAT_CD" type="java.lang.String" />
         <property name="reviewBeginDate" column="B_ON_REVW_BEG_DT" type="java.util.Date" />   
         <property name="reviewEndDate" column ="B_ON_REVW_END_DT" type="java.util.Date" />
         <property name="deliveryUpdatedDate" column="B_DLVRY_UPD_DT" type="java.util.Date" />   
         <property name="updateVerification" column ="B_UPD_VRFY_CD" type="java.lang.String" />
         <property name="updateDateOfDeathUserID" column="B_DOD_UPD_USER_ID" type="java.lang.String" />
         <property name="hsCompletionInd" column ="B_HS_COMP_IND" type="java.lang.String" />   
         <property name="omitFromArchiveIndicator" column="B_OMIT_FROM_ARCH_IND" type="java.lang.String" />
         <property name="forceMSQIndicator" column="B_BYPS_MSQ_IND" type="java.lang.String" />
         <property name="hchkLetterIndicator" column ="B_HCHK_LTR_IND" type="java.lang.String" />

         <component name="employmentInfo" class="com.acs.enterprise.mmis.member.common.domain.EmploymentInformation" insert="true" update="true">
            <property name="workExpenseAmt" column="B_WORK_EXP_AMT" type="java.lang.Double" />
            <property name="firstEmploymentDate" column="B_FIRST_EMP_DT" type="java.util.Date" />
            <property name="individualGrossAmt" column="B_INDIV_GROSS_AMT" type="java.lang.Double" />
            <property name="individualNetAmt" column="B_INDIV_NET_AMT" type="java.lang.Double"/>
            <property name="workHistoryInd" column="B_WORK_HIST_IND" type="yes_no"/>         
         </component>
         
         <component name="pregnancyInfo" class="com.acs.enterprise.mmis.member.common.domain.PregnancyInformation" insert="true" update="true">
            <property name="pregnancyDueDate" column="B_PREG_DUE_DT" type="java.util.Date" />
            <property name="pregnancyTermDate" column="B_PREG_TERM_DT" type="java.util.Date" />
            <property name="noOfChildrenExpected" column="B_PREG_EXPT_NUM" type="java.lang.Integer" />   
            <property name="pcpForNewBornAltID" column="P_NEWBORN_PCP_ALT_ID" type="java.lang.String"/>   
            <property name="pcpForNewBornAltIDTypeCode" column="P_NEWBORN_PCP_ALT_ID_TY_CD" type="java.lang.String"/>
            <!-- Association between B_DTL_TB & P_DETAIL_TB tables -->
            <many-to-one name="pcpForNewBorn" class="com.acs.enterprise.mmis.provider.common.domain.Provider"
               column="P_NEWBORN_PCP_SYS_ID" lazy="proxy"/>          
         </component>

         <component name="name" class="com.acs.enterprise.common.base.common.domain.Name" insert="true" update="true">
            <property name="firstName" column="B_FIRST_NAM" type="java.lang.String"/>
            <property name="lastName" column="B_LAST_NAM" type="java.lang.String"/>
            <property name="middleName" column="B_MID_NAM" type="java.lang.String"/>
            <property name="suffixName" column="B_SFX_NAM" type="java.lang.String"/>
         </component>

         <!-- Association between B_DTL_TB & B_ALT_ID_TB tables -->
         <set name="alternateMemberID" table="B_ALT_ID_TB" inverse="true" lazy="true" cascade="all" outer-join="true" >
               <key column="B_SYS_ID" />
               <one-to-many class="com.acs.enterprise.mmis.member.common.domain.AlternateMemberID" />
         </set>

         <!-- Association between B_DTL_TB & B_RACE_TB tables -->
         <set name="race" table="B_RACE_TB" inverse="true" lazy="true" cascade="all" >
            <key column="B_SYS_ID"/>
            <one-to-many class="com.acs.enterprise.mmis.member.common.domain.Race" />
         </set>

         <!-- Association between B_DTL_TB & B_DISA_TB tables -->
         <set name="disabilityInfo" table="B_DISA_TB" inverse="true" order-by="B_DISA_BEG_DT desc" lazy="true" cascade="all" >
            <key column="B_SYS_ID" />
            <one-to-many class="com.acs.enterprise.mmis.member.common.domain.DisabilityInformation" />
            <filter name="asOfDate"
               condition="trunc(:asOfDate) BETWEEN trunc(B_DISA_BEG_DT) and trunc(B_DISA_END_DT)"/>
         </set>

         <!-- Association between B_DTL_TB & B_SPCT_DUPL_TB tables -->
         <set name="suspectDuplicate" table="B_SPCT_DUPL_TB" inverse="true" lazy="true" cascade="all" >
            <key column="B_SYS_ID" />
            <one-to-many class="com.acs.enterprise.mmis.member.common.domain.SuspectDuplicate" />
         </set>

      </component>
   </class>
</hibernate-mapping>


when i am trying to fetch the component using HQL i am able to get the ordinary properties but not able to fetch the collections. Interestingly my query generated by Hibernate is fetching the collections but when i am trying to fetch them in my DAO i am getting null pointer exception.

Below is the code in my DAO method.
Code:
public DemographicInformation getDemographicInformation(String memberAltID, String memberAltIDTypeCode, boolean disabilityInfoReq) throws MemberDataRetrievalException
   {
       logger.info(beginMethod);
       DemographicInformation demographicInformation = null;
      List memberList = null;
      StringBuffer sb = new StringBuffer(1000);
      try
      {
          sb.append(" select member.demographicInformation from Member as member left join fetch member.demographicInformation.alternateMemberID as altMember left join fetch member.demographicInformation.suspectDuplicate as suspectDuplicate ");
          sb.append(" select altMember from Member as member left join fetch member.demographicInformation.alternateMemberID as altMember ");
          if(disabilityInfoReq)
          {
              sb.append(" left join fetch member.demographicInformation.disabilityInfo as disabilityInfo ");
          }
          sb.append(" where altMember.altID = :memberAltID and altMember.altIDTypeCode = :memberAltIDTypeCode ");
         Query query = session.createQuery(sb.toString());
         query.setParameter("memberAltID", memberAltID);
         query.setParameter("memberAltIDTypeCode", memberAltIDTypeCode);
         memberList = query.list();         
          if (memberList != null && memberList.size() > 0)
         {
            Set distinctMemberDetails = new HashSet(memberList);
            demographicInformation = (DemographicInformation) distinctMemberDetails.iterator().next();
         }
      } catch (HibernateException hException)
      {
         //log the exception using log4j. For now print the exception
         hException.printStackTrace();
         throw new MemberDataRetrievalException("DB_MEM_INQ_0005", hException);
      }
      logger.info(endMethod);
      return demographicInformation;
   }


Following is the query generated by Hibernate:
Code:
SELECT   disability3_.b_disa_beg_dt AS b1_9_0_,
         disability3_.b_disa_cd AS b2_9_0_, disability3_.b_sys_id AS b3_9_0_,
         alternatem1_.b_alt_id AS b1_13_1_,
         alternatem1_.b_alt_id_ty_cd AS b2_13_1_,
         alternatem1_.b_sys_id AS b3_13_1_, suspectdup2_.b_sys_id AS b1_20_2_,
         suspectdup2_.b_spct_dupl_sys_id AS b2_20_2_,
         disability3_.b_disa_void_ind AS b4_9_0_,
         disability3_.b_disa_end_dt AS b5_9_0_,
         disability3_.g_aud_user_id AS g6_9_0_,
         disability3_.g_aud_ts AS g7_9_0_,
         disability3_.g_aud_add_user_id AS g8_9_0_,
         disability3_.g_aud_add_ts AS g9_9_0_,
         alternatem1_.r_lob_cd AS r4_13_1_,
         alternatem1_.b_alt_id_src_cd AS b5_13_1_,
         alternatem1_.g_aud_user_id AS g6_13_1_,
         alternatem1_.g_aud_ts AS g7_13_1_,
         alternatem1_.g_aud_add_user_id AS g8_13_1_,
         alternatem1_.g_aud_add_ts AS g9_13_1_,
         suspectdup2_.b_spct_dupl_rsn_cd AS b3_20_2_,
         suspectdup2_.b_spct_dupl_prcs_cd AS b4_20_2_,
         suspectdup2_.b_txn_src_cd AS b5_20_2_,
         suspectdup2_.g_aud_user_id AS g6_20_2_,
         suspectdup2_.g_aud_ts AS g7_20_2_,
         suspectdup2_.g_aud_add_user_id AS g8_20_2_,
         suspectdup2_.g_aud_add_ts AS g9_20_2_,
         disability3_.b_sys_id AS b3___, disability3_.b_disa_beg_dt AS b1___,
         disability3_.b_disa_cd AS b2___, member0_.p_pe_alt_id AS col_0_0_,
         member0_.p_pe_alt_id_ty_cd AS col_0_1_,
         member0_.b_phntc_first_nam AS col_0_2_,
         member0_.b_phntc_last_nam AS col_0_3_,
         member0_.b_confid_cd AS col_0_4_, member0_.b_dob_dt AS col_0_5_,
         member0_.b_dod_upd_dt AS col_0_6_, member0_.b_vip_ind AS col_0_7_,
         member0_.b_dem_lock_cd AS col_0_8_,
         member0_.b_ssn_vrfy_cd AS col_0_9_,
         member0_.b_mcare_vrfy_cd AS col_0_10_,
         member0_.b_dept_cd AS col_0_11_, member0_.b_gender_cd AS col_0_12_,
         member0_.b_eth_cd AS col_0_13_, member0_.b_lang_cd AS col_0_14_,
         member0_.b_citizen_cd AS col_0_15_,
         member0_.b_lv_arrange_cd AS col_0_16_,
         member0_.b_mrtl_stat_cd AS col_0_17_,
         member0_.b_case_form_num AS col_0_18_,
         member0_.b_dod_dt AS col_0_19_, member0_.b_dod_vrfy_cd AS col_0_20_,
         member0_.b_appl_dt AS col_0_21_, member0_.b_cert_dt AS col_0_22_,
         member0_.b_expt_confnmt_dt AS col_0_23_,
         member0_.b_tribal_affl_cd AS col_0_24_,
         member0_.b_fam_stat_cd AS col_0_25_,
         member0_.b_on_revw_beg_dt AS col_0_26_,
         member0_.b_on_revw_end_dt AS col_0_27_,
         member0_.b_dlvry_upd_dt AS col_0_28_,
         member0_.b_upd_vrfy_cd AS col_0_29_,
         member0_.b_dod_upd_user_id AS col_0_30_,
         member0_.b_hs_comp_ind AS col_0_31_,
         member0_.b_omit_from_arch_ind AS col_0_32_,
         member0_.b_byps_msq_ind AS col_0_33_,
         member0_.b_hchk_ltr_ind AS col_0_34_,
         member0_.b_work_exp_amt AS col_0_35_,
         member0_.b_first_emp_dt AS col_0_36_,
         member0_.b_indiv_gross_amt AS col_0_37_,
         member0_.b_indiv_net_amt AS col_0_38_,
         member0_.b_work_hist_ind AS col_0_39_,
         member0_.b_preg_due_dt AS col_0_40_,
         member0_.b_preg_term_dt AS col_0_41_,
         member0_.b_preg_expt_num AS col_0_42_,
         member0_.p_newborn_pcp_alt_id AS col_0_43_,
         member0_.p_newborn_pcp_alt_id_ty_cd AS col_0_44_,
         member0_.p_newborn_pcp_sys_id AS col_0_45_,
         member0_.b_first_nam AS col_0_46_, member0_.b_last_nam AS col_0_47_,
         member0_.b_mid_nam AS col_0_48_, member0_.b_sfx_nam AS col_0_49_
    FROM b_dtl_tb member0_,
         b_alt_id_tb alternatem1_,
         b_spct_dupl_tb suspectdup2_,
         b_disa_tb disability3_
   WHERE member0_.b_sys_id = alternatem1_.b_sys_id(+)
     AND member0_.b_sys_id = suspectdup2_.b_sys_id(+)
     AND member0_.b_sys_id = disability3_.b_sys_id(+)
     AND ((alternatem1_.b_alt_id = '123456789') AND (alternatem1_.b_alt_id_ty_cd = 'MID'))
ORDER BY disability3_.b_disa_beg_dt DESC


I am not able to figure out the exact reason why i am not able to fetch the collections present in component?

Please let me know the exact way of fetching the collections in components.

Thanks in Advance.


Regards
Ravi.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.