BigInteger 转 BigDecimal 问题
来源:互联网 发布:斑马条码打印机软件 编辑:程序博客网 时间:2024/06/05 00:20
从数据库取出一个 Count函数 统计的值
在代码中要转成Integer类型的时候
String sqlCount = "SELECT count(1) "+
"FROM (t_mch_XXX s LEFT JOIN t_bank_XXX b ON s.`CODE` = b.CUST_ID) "+
"LEFT JOIN t_cls_XXX t ON s.`CODE` = t.MCH_CODE "+
"WHERE t.SETTLE_DATE>? AND t.SETTLE_DATE<? AND s.CLS_MODE = 'INDIRECT' AND t.AMOUNT_SETTLE > 0";
Query queryCount = addQueryParams(getEntityManager().createNativeQuery( sqlCount ),
new Object[]{search.getSettleDate().getStart(),search.getSettleDate().getEnd()});
java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.math.BigDecimal
也试过这种方法 BigDecimal decimal = (BigDecimal)queryCount.getSingleResult() == null ? 0:queryCount.getSingleResult() ; 还是报同样的错 。
最后 ,使用绝招 ,不是不能转么,那就直接用 BigInteger
Object count = queryCount.getSingleResult() == null ? 0:queryCount.getSingleResult();
BigInteger i= (BigInteger)count;
这样就行了 。
- BigInteger 转 BigDecimal 问题
- BigDecimal+BigInteger
- BigInteger和BigDecimal
- Math Random BigInteger BigDecimal
- java BigInteger和BigDecimal
- BigDecimal和BigInteger详解
- BigInteger 和 BigDecimal
- BigInteger与BigDecimal
- BigInteger和BigDecimal
- java BigInteger,BigDecimal学习
- java BigInteger BigDecimal类
- BigInteger、BigDecimal、数字格式化
- BigDecimal 和 BigInteger
- Java大数-BigInteger BigDecimal
- BigInteger和BigDecimal类
- Java大数BigInteger BigDecimal
- JAVA BigDecimal and BigInteger
- 高精度运算类(BigInteger,BigDecimal)
- STM32用SPI方式控制OLED模块
- mysql分组取每组前几条记录(排序)
- iOS开发:设置App名称,设置App icon图标,设置App启动图
- android TextView(4)-SpannableString&SpannableStringBuffer定制文本
- ReactNative 学习资源大汇集
- BigInteger 转 BigDecimal 问题
- jquery 封装插件
- Ubuntu下好用的音乐播放器Audacious
- canvas仿知乎登录页面动画
- 《Netty超时设置不起作用》---超时相关handler注意事项
- 【Spring 核心】(3):SpringMVC 的实现
- NSError 解析
- 值类型和引用类型
- 使用hexo+github搭建个人微博——手把手教