We are migrating an old codebase from Hibernate 2 to Hibernate 5. For historical reasons (mostly performance) this codebase uses the BigDecimal implementation from ICU project and not the standard one from Java. We've implemented a custom Hibernate type for it. However we are encountering issues with queries such as follows:
select new some.package.Scalar(sum (a.amount / 2) from some.package.PersistentClass as a where ...
In this instance the a.amount property has the custom type ICUBigDecimalType, however the BinaryArithmeticOperatorNode calculates the data type type of the expression as IntegerType. This happens because this class only handles a subset of standard Hibernate types and doesn't handle custom types. The result is that Hibernate fails to match correctly the constructor of the instantiated result class. I didn't find any documentation of this use case. Is this a known issue and custom user types cannot be used in HQL's arithmetic expressions? If not then we'd like to see some kind of hook to allow custom user types to decide how types should be resolved. |