Issue Type: Bug Bug
Affects Versions: 3.6.10
Assignee: Unassigned
Attachments: sum-return-type.tgz
Components: core
Created: 25/Jul/12 2:17 PM
Description:

The implementation of getReturnType in org.hibernate.dialect.function.StandardAnsiSqlAggregationFunctions.SumFunction ignores custom user types, instead falling back to the underlying JDBC type code. Worse still, a user type with a jdbcType of DECIMAL results in a type for the sum aggregation of double.

We have a Money type, and a corresponding MoneyUserType which converts between java Money instances and database decimal columns. In hibernate 3.2.5, if amount was a Money property, Projections.sum(amount) would return a Money instance. As of 3.6.10, it returns a double.

At bare minimum, sum in this case should return an instance of BigDecimal, so as to avoid the usaual problems of doing floating point arithmetic with monetary amounts. Ideally, it should continue to use the user type of the summed column.

Environment: Hibernate 3.6.10-Final, any database (confirmed with Oracle 11g and Hsqldb)
Project: Hibernate ORM
Priority: Major Major
Reporter: Ian Robertson
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira