0

I'm using spring boot 1.5, I want to get alerts grouped by their status (four status).thereby I'm using a native query in the repository. when I run that query it's giving me the result. but it doesnt work with the service. the result I've got when I run with the console : https://drive.google.com/open?id=1eson3nEHAIEr-jdEgkC1-tw2acRsW728

the service is :

  @Override
public List<DashboardAlertVO> countingStatus() {
    return alertRepository.countStatus()
            .stream()
            .map(o -> new DashboardAlertVO(AlertStatus.fromValue((String) o[0]),
                    ((Integer) o[1])))
            .collect(Collectors.toList());
}

so I'm getting this error :

"message": "java.math.BigInteger cannot be cast to java.lang.Integer",

I don't know what's matter really with this code. Please help ! Thank you a lot.

1 Answer 1

1

We can not type cast BigInteger to Integer by simply using integer keyword. Instead you should use the inbuilt method intValue() of BigInteger class to get the integer part.

@Override
public List<DashboardAlertVO> countingStatus() {
    return alertRepository.countStatus()
        .stream()
        .map(o -> new DashboardAlertVO(AlertStatus.fromValue((String) o[0]),
                (o[1].intValue())))
        .collect(Collectors.toList());
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.