Criteria SUM expression return type error

Description

The return type of the SUM function over an Integer type column in the Criteria API has changed from Long to Integer. In the old version, with an explicitly defined return type:
CriteriaQuery<Integer> criteria = builder.createQuery( Integer.class );
the result was of type Integer.

In the case where I defined the query as:
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
the value in the resulting Tuple was of type Long.

After the upgrade, the return type is Integer in both cases.

Activity

Show:

Yoann Rodière March 17, 2025 at 10:16 AM

Yoann Rodière March 17, 2025 at 10:15 AM

Closing at reporter’s request: #hibernate-user > ✔ Criteria sum function return type @ 💬

Gavin King March 17, 2025 at 9:43 AM

If you’re calling CriteriaBuilder.sum() on a field of type Integer, then Integer is indeed the correct result type.

Rejected

Details

Assignee

Reporter

Worked in

Components

Affects versions

Priority

Created March 17, 2025 at 9:24 AM
Updated March 17, 2025 at 10:16 AM
Resolved March 17, 2025 at 10:15 AM