HQL removing parenthesis from arithmetic operations
-
21-06-2021 - |
题
Following HQL:
"-(a.import + a.bill)"
gets translated to following SQL:
"-a.import + a.bill"
instead of expected:
"-(a.import + a.bill)"
This makes the operation to calculate a result diferent from what is expected.
The translation has been proved with org.hibernate.dialect.Oracle10gDialect and with org.hibernate.dialect.HSQLDialect
Hibernate's version is 3.5.1-Final
Does anybody knows why is this happening? is this a bug?
解决方案
It happens because of bug HHH-6714. Solution is to update Hibernate to newer version. If you have to stick with 3.x, then 3.6.9 or newer. In 4.x any stable release goes, because it was fixed in 4.0.0.CR6.
I tried with 3.6.10 and parentheses remained.
不隶属于 StackOverflow