• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

mybatis查询报空指针异常java.lang.NullPointerException

武飞扬头像
思凡04
帮助1

操作失败,nested exception is org.apache.ibatis.exceptions.PersistenceException: 
\n### Error querying database.  
Cause: java.lang.NullPointerException\n### 
The error may exist in cn/com/icbf/operationanalysis/mapper/AccountCustomerDataAnalysisMapper.xml\n### The error may involve 
cn.com.icbf.operationanalysis.mapper.AccountCustomerDataAnalysisMapper.cbcAppointCaseAmount\n### 
The error occurred while handling results
\n### SQL: select sum(cbc_commission_amount) from         account_customer_data_analysis          WHERE customer= ?\n### Cause: java.lang.NullPointerException

这个时候查看一下sql查询出的数据是不是NULL,而实体的类型是不是不能为空
我这里的报错是我的字段类型是Bigdecimal而查出来的是null所以需要在sql加上判断:
IFNULL(sum(cbc_commission_amount),0)

select IFNULL(sum(cbc_commission_amount),0) fromaccount_customer_data_analysis

判断不为空就可以正常

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgkaefj
系列文章
更多 icon
同类精品
更多 icon
继续加载