java.math.BigInteger cannot be cast to java.lang.Integer的解决方法

在使用hibernate2进行原生的sql的单个结果的查询时,比如sql:select count(*) from 表,返回的是一个object类型的值。

转换为int类型:

1、先转成String类型,String str=obj.toString();

2、然后使用Integer的parseInt(str)或者valueOf(str)转换成int类型就行了

int num = Integer.valueOf(str);

猜你喜欢

转载自blog.csdn.net/ryuhfxz/article/details/82117256