Criteria arithmetic takes its result type from both operands

The result type of CriteriaBuilder.sum, diff, prod, quot and neg now follows the numeric promotion rules of section 4.8.6 of the specification: Double if an operand is Double, else Float, BigDecimal, BigInteger, Long and Integer, in that order. Previous releases used the type of the first operand, or Number when the first operand was a literal, and did not convert the value the database returned. For example, cb.sum(intPath, longPath) now returns a Long instead of an Integer, cb.sum(intPath, 2.5) returns a Double instead of a truncated Integer, and cb.neg(intPath) returns an Integer on databases such as MySQL that compute integer arithmetic as BIGINT. Expression.getJavaType() of these expressions changes the same way.

Application code that casts such results must be adapted to the new type or to Number.