-->
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: Mapping nested components to Stored Procedure
PostPosted: Wed Mar 26, 2008 4:37 pm 
Newbie

Joined: Wed Mar 26, 2008 4:27 pm
Posts: 3
Hi,

I'm trying to map nested components to a Stored Procedure. The class def looks like this:

Code:
<hibernate-mapping package="com.test.model"> 
   <class name="Holding" mutable="false">   
      <id name="policyNumber" column="POLICYNUMBER"/>   
      <property name="assetValue" type="big_decimal" />   
      <property name="liabilityValue" type="big_decimal" />   
      <property name="distributorClientAcctNum" type="string" />     
      
      <!-- 1st level of nesting -->     
      <component name="policy" class="com.objectedge.acord.model.Policy">     
         <property name="policyStatusCode" type="string" />     
         <property name="certificateNo" type="string"/>       
         <property name="productTypeCode" type="string"/>       
         <property name="cusipNum" type="string"/>       

         <!-- 2nd level of nesting -->     
         <component name="annuity" class="com.objectedge.acord.model.Annuity">       
            <property name="cumWthdrwlAmtYTD" type="big_decimal"/>       
            <property name="netWthdrwlAmtYTD" type="big_decimal"/>         
            <property name="surrenderValue" type="big_decimal"/>         
            <property name="initDepositAmt" type="big_decimal"/>       
            <property name="totalDepositITD" type="big_decimal"/>       
            <property name="grossPremPriorYr" type="big_decimal"/>       
         </component>     
      </component>   
   </class>
</hibernate-mapping>



After struggling a bit to try and map this to a stored procedure I got it to work with this <sql-query> block:

Code:

<sql-query name="getHOLDING" callable="true"> 
   <return alias="Holding" class="Holding">   
      <return-property name="policyNumber" column="POLICYNUMBER"/>   
      <return-property name="assetValue" column="ASSETVALUE"/>   
      <return-property name="liabilityValue" column="LIABILITYVALUE"/>   
      <return-property name="distributorClientAcctNum" column="DISTRIBUTORCLIENTACCTNUM"/>     

      <!-- Policy component columns -->      
      <return-property name="policy">     
         <return-column name="POLICYSTATUSTC"/>     
         <return-column name="CERTIFICATENO"/>       
         <return-column name="PRODUCTTYPETC"/>               
         <return-column name="CUSIPNUM"/>             

         <!-- Annuity component columns -->     
         <return-column  name="CUMWTHDRWLAMTYTD"/>     
         <return-column  name="NETWTHDRWLAMTYTD"/>              
         <return-column  name="SURRENDERVALUE"/>              
         <return-column  name="INITDEPOSITAMT"/>     
         <return-column  name="TOTALDEPOSITITD"/>     
         <return-column  name="GROSSPREMPRIORYR"/>      
      </return-property>          
   </return>  { call TXLIFE.ASE_HOLDING(?,   :POLNUMBER) }
</sql-query>


Is the the correct way to do this? If not can you please let me know how to map it?

Thanks,

Tausif


Top
 Profile  
 
 Post subject: Read the Documentation
PostPosted: Thu Mar 27, 2008 6:03 am 
Newbie

Joined: Wed Mar 26, 2008 5:59 am
Posts: 2
Hi !

I'm new in Hibernate but I have been working using Stored Procedures and I think you can not use nested components.

I have some working mappings and they look like this:
<hibernate-mapping>
<class name="pt.company.comuns.adp.vo.ObterBloqueio" schema="ADM">
<composite-id name="id" class="pt.company.comuns.adp.vo.ObterBloqueioId">
<key-property name="cfrConReg" type="java.lang.String" column="CFR_COD_REG" length="15" />
<key-property name="cfrCodTip" type="java.lang.String" column="CFR_COD_TIP" length="3" />
<key-property name="cfrCodOpr" type="java.lang.String" column="CFR_COD_OPR" length="7" />
<key-property name="cfrCodConta" type="java.lang.String" column="CFR_COD_CONTA" length="8" />
<key-property name="cfrCodReg1" type="java.lang.String" column="CFR_COD_REG_1"/>
<key-property name="cfrCodOpr1" type="java.lang.String" column="CFR_COD_OPR_1"/>
</composite-id>
<property name="cfrConBanCli" type="java.lang.Long">
<column name="CFR_CON_BAN_CLI" length="9" not-null="true" />
</property>
<property name="cfrConBanNat" type="java.lang.Long">
<column name="CFR_CON_BAN_NAT" length="2" not-null="true" />
</property>
<property name="cfrConBanSeq" type="java.lang.Long">
<column name="CFR_CON_BAN_SEQ" length="3" not-null="true" />
</property>
<property name="cfrCodEst" type="java.lang.String">
<column name="CFR_COD_EST" not-null="true" />
</property>
<property name="dataCriacao" type="java.util.Date">
<column name="DATA_CRIACAO" not-null="true" />
</property>
<property name="cfrTexto" type="java.lang.String">
<column name="CFR_TEXTO" not-null="true" />
</property>
<property name="cfrCodMov" type="java.lang.String">
<column name="CFR_USR_MOV" not-null="true" />
</property>
<property name="cfrDatMov" type="java.util.Date">
<column name="CFR_DAT_MOV" not-null="true" />
</property>
<property name="cfrChnMov" type="java.lang.String">
<column name="CFR_CHN_MOV" not-null="true" />
</property>
<property name="cfrCodTit" type="java.lang.String">
<column name="CFR_CODTIT" length="9" not-null="false"/>
</property>
<property name="cfrCofre" type="java.lang.String">
<column name="CFR_COFRE" length="2" not-null="false"/>
</property>
<property name="cfrQt" type="java.lang.Long">
<column name="CFR_QT" not-null="false"/>
</property>
<property name="cfrGrau" type="java.lang.Long">
<column name="CFR_GRAU" length="2" not-null="false"/>
</property>

</class>

<sql-query name="ObterBloqueio" callable="true">
<return class="pt.company.comuns.adp.vo.ObterBloqueio">
<return-property name="id">
<return-column name="CFR_COD_REG"/>
<return-column name="CFR_COD_TIP"/>
<return-column name="CFR_COD_OPR"/>
<return-column name="CFR_COD_CONTA"/>
<return-column name="CFR_COD_REG_1"/>
<return-column name="CFR_COD_OPR_1"/>
</return-property>
<return-property name="cfrConBanCli" column="CFR_CON_BAN_CLI"/>
<return-property name="cfrConBanNat" column="CFR_CON_BAN_NAT"/>
<return-property name="cfrConBanSeq" column="CFR_CON_BAN_SEQ"/>
<return-property name="cfrCodEst" column="CFR_COD_EST"/>
<return-property name="dataCriacao" column="DATA_CRIACAO"/>
<return-property name="cfrTexto" column="CFR_TEXTO"/>
<return-property name="cfrCodMov" column="CFR_USR_MOV"/>
<return-property name="cfrDatMov" column="CFR_DAT_MOV"/>
<return-property name="cfrChnMov" column="CFR_CHN_MOV"/>
<return-property name="cfrCodTit" column="CFR_CODTIT"/>
<return-property name="cfrCofre" column="CFR_COFRE"/>
<return-property name="cfrQt" column="CFR_QT"/>
<return-property name="cfrGrau" column="CFR_GRAU"/>
</return>
{ call WSP_GET_MOVBLOQ_HOST(?, :CFR_CON_BAN_CLI, :CFR_CON_BAN_NAT, :CFR_CON_BAN_SEQ, :CFR_COD_EST) }
</sql-query>
</hibernate-mapping>

The Stored Procedure returns some data on a cursor and I have a composite id in this case.
The database is Oracle 8i.

Read the following URL on Chapter 16.2 http://www.hibernate.org/hib_docs/v3/re ... procedures

about some limitations issues!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 27, 2008 12:23 pm 
Newbie

Joined: Wed Mar 26, 2008 4:27 pm
Posts: 3
Thanks brunooliveira2008 for the response. I followed the link that you provided but couldn't find anything mentioned about nested components and stored procs. The funny thing is that the way I have mapped my stored proc return columns to the nested components (as shown in my first post) works! The only problem I have is that I don't know if its supposed to work this way or is it an unknown feature (read bug).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 07, 2008 8:25 pm 
Newbie

Joined: Wed Mar 26, 2008 4:27 pm
Posts: 3
Anybody?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2008 10:36 am 
Newbie

Joined: Sat Nov 29, 2008 10:32 am
Posts: 1
Hi
you can see this link
http://www.hibernate.org/hib_docs/reference/en/html/querysql-namedqueries.html


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.