I am trying to execute a SQL summarization query as follows:
select group_ID, sum(case when user_type = 'Exec' then 1000
when user_type = 'Office' then 10 else 0 end)
from subscription
group by group_ID;
using the following code snippet from a CriteriaBuilder request:
criteriaBuilder.sum(
criteriaBuilder.selectCase()
.when(criteriaBuilder.equal(subscriptionJoin.get(Subscription_.userType), "Exec"),1000)
.when(criteriaBuilder.equal(subscriptionJoin.get(Subscription_.userType), "Office"),1)
.otherwise(101))
However, the following compilation error appears:
The deduced type 'java.lang.object' for a parameter of type 'N' is not within its boundary; should extend 'java.lang.number'
Any idea how to support summation execution using selectCase?
source
share