Types problem with ProjectionList in criteria

0

I have a problem with java giving the following error:

in class: com.app.myApp.ReportDTO, setter method of property: indicator
expected type: java.lang.Double, actual value: java.lang.IntegerInteger

What happens in my criteria when creating a projecitonList , setting a projection as SUM :

projectionList.add(Projections.sum(propertyIndicator), "indicator");

When giving criteria.List(); the error is popped. The strange thing is that when I used the avg function, instead of sum, it worked normally, without error.

From what I saw, the error occurs because my propertyIndicator is an Integer , and the property "indicator" is a Double . Can I convert these properties to the sum function?

    
asked by anonymous 18.02.2016 / 16:43

1 answer

1

Could not make an explicit conversion within Projections.sum , so I had to go in search of other resources, and changed the setter of my DTO to receive a Integer as parameter, and within the same make the property conversion to double :

public void setIndicator(Integer indicator) {
        if (indicator != null) {
            this.indicator = Double.valueOf(indicator.doubleValue());
        } else {
            this.indicator = null;
        }
    } 
    
19.02.2016 / 11:54