-->
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: SUM returns Double (better documentation needed?)
PostPosted: Fri Nov 16, 2007 8:16 am 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
I have a query that is summing a field with datatype float and constructing a new Bean based on the result. eg:
Code:
select new FreightSummaryBean(f, sum(fl.convertedAmount), sum(fl.carrierCurrencyAmount)) from FreightInvoice f left join f.freightInvoiceLines as fl
...etc etc

I had trouble specifying the correct constructor for the FreightSummaryBean.

The Hibernate in Action book implies that the datatype of the sum will be the datatype of the field being summed ("The query returns a BigDecimal because the amount property is of type BigDecimal. The sum() function also recognizes BigInteger property types and returns Long for all other numeric property types...").

As you can see from the subject, the SUM actually returns a Double.

This page from the NHibernate Migration guide has the only statement that floats return Double. http://www.hibernate.org/407.html

Have I missed some documentation somewhere? I would have thought that this info would have been in the core docs.

Cheers,

Damian.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 16, 2007 8:21 am 
Beginner
Beginner

Joined: Thu May 17, 2007 8:37 am
Posts: 22
Location: London
Ah, I see. It's a JPA spec thing.

http://weblogs.java.net/blog/mb124283/archive/2007/04/java_persistenc.html


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.