FunctionArgumentException after hibernate upgrade to v6.4.4

Hello,
I’ve recently upgraded a project to spring boot 3.2.4, hibernate 6.4.4 (from 5.6.15)

We have this criteria builder in our code

    private Selection<?> buildFieldSelection(GroupingType groupingType, Field field, Root<T> root)
    {
        final String fieldName = field.getName();

        return criteriaBuilder.selectCase().when(criteriaBuilder.equal(criteriaBuilder.sum(countIsNull, countIsNotNull), 1L), criteriaBuilder.max(root.get(fieldName))).alias(fieldName);

This used to work but now when the fieldName is that of a Boolean field we get an error like :

Caused by: org.hibernate.query.sqm.produce.function.FunctionArgumentException: Parameter 1 of function 'max()' has type 'COMPARABLE', but argument is of type 'java.lang.Boolean'

	at org.hibernate.query.sqm.produce.function.ArgumentTypesValidator.throwError(ArgumentTypesValidator.java:303) ~[hibernate-core-6.4.4.Final.jar:6.4.4.Final]

This works okay with other types of fields – strings, dates etc

I have tried with different versions e.g. 6.2.0 and 7.0.0

I’m not sure how to update our code to get this to work – any help would be very much appreciated.

Many thanks,

Richard

This is a bug. Please create a Jira issue for this and attach a reproducer. You can alternatively use the aggregate function bool_or/any if you want to know whether one of the aggregated rows produces true.

Thank you, I have created this Jira ticket: [HHH-18016] - Hibernate JIRA and will add a demo project to reproduce the error

1 Like