ClassCastException when using SUM() on subquery root

Description

I think it’s related to https://hibernate.atlassian.net/browse/HHH-17223 but in this case it occurs when using subquery:

JpaCriteriaQuery<Integer> query = cb.createQuery(Integer.class); JpaSubQuery<Tuple> subquery = query.subquery(Tuple.class); JpaRoot<Primary> sqRoot = subquery.from(Primary.class); subquery.multiselect( sqRoot.get("id").alias("id"), sqRoot.get("capacity").alias("capacity") ); JpaDerivedRoot<Tuple> root = query.from(subquery); query.select( cb.sum(root.get("capacity")) ); Integer result = entityManager.createQuery(query).getSingleResult();

and the exception is:

java.lang.ClassCastException: class org.hibernate.query.derived.AnonymousTupleSqmPathSource cannot be cast to class org.hibernate.query.ReturnableType

If this case was also fixed in https://hibernate.atlassian.net/browse/HHH-17223 the please close this issue.

Attachments

1
  • 27 Sep 2023, 07:48 AM

Activity

Show:
Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Affects versions

Priority

Created September 27, 2023 at 7:46 AM
Updated October 26, 2023 at 3:34 PM
Resolved October 4, 2023 at 5:20 PM

Flag notifications