-->
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: Hibernate 3.5.2 and formulas on property element
PostPosted: Mon May 31, 2010 4:19 am 
Newbie

Joined: Mon May 31, 2010 2:42 am
Posts: 1
Hibernate 3.5.2 introduced a bug when it comes to formula for derived properties. (we have noticed it when we migrated to the latest version from 3.2.3.ga )

We have the following in one of our hbm files.
Code:

<component name="originalAmount" class="com.uprr.app.ama.model.charge.Money">
         <property name="value" type="big_decimal" length="11" formula="( SELECT SUM (li.ORGL_BILL_LINE_ITEM_AMT) FROM AMA_BILL_LINE_ITEM li WHERE li.ACCR_BILL_ID = ACCR_BILL_ID)" />
      </component>


Hibernate 3.2.3.ga generates the SQL query like a charm (Notice the bold part):

Code:
select this_.ACCR_BILL_ID as ACCR1_30_18_,
       this_.ARMS_RCVB_ID as ARMS2_30_18_,
       this_.RCVB_BILL_SRC as RCVB3_30_18_,
       this_.BILL_NBR as BILL4_30_18_,
       this_.BILL_ACCT_NBR as BILL5_30_18_,
       this_.EQMT_INIT as EQMT6_30_18_,
       this_.EQMT_NBR as EQMT7_30_18_,
       this_.BILD_USER_ID as BILD8_30_18_,
       this_.BILD_DATE as BILD9_30_18_,
       this_.LAST_UPTD_USER_ID as LAST10_30_18_,
       this_.LAST_UPTD_DT as LAST11_30_18_,
       this_.PROC_ST_ID as PROC12_30_18_,
       ([b]SELECT SUM(li.ORGL_BILL_LINE_ITEM_AMT)
          FROM AMA_BILL_LINE_ITEM li
         WHERE li.ACCR_BILL_ID = this_.ACCR_BILL_ID) as formula0_18_[/b],
       :
       : and so on



However hibernate 3.5.2 seizes to render the SQL properly, it generates the following erroneous query (notice the bolded-italic part ) :

Quote:

select this_.ACCR_BILL_ID as ACCR1_30_18_,
this_.ARMS_RCVB_ID as ARMS2_30_18_,
this_.RCVB_BILL_SRC as RCVB3_30_18_,
this_.BILL_NBR as BILL4_30_18_,
this_.BILL_ACCT_NBR as BILL5_30_18_,
this_.EQMT_INIT as EQMT6_30_18_,
this_.EQMT_NBR as EQMT7_30_18_,
this_.BILD_USER_ID as BILD8_30_18_,
this_.BILD_DATE as BILD9_30_18_,
this_.LAST_UPTD_USER_ID as LAST10_30_18_,
this_.LAST_UPTD_DT as LAST11_30_18_,
this_.PROC_ST_ID as PROC12_30_18_,
(SELECT this_.SUM(li.ORGL_BILL_LINE_ITEM_AMT)
FROM AMA_BILL_LINE_ITEM li
WHERE li.ACCR_BILL_ID = this_.ACCR_BILL_ID) as formula0_18_
,



It should not add alias for
Quote:
SUM


Is it a bug in the latest version, or do we have to tweak a bit to make it work ?


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.