首页 > 其他 > 详细

attempted to return null from a method with a primitive return type (double)

时间:2017-06-11 23:07:22      阅读:2669      评论:0      收藏:0      [点我收藏+]

attempted to return null from a method with a primitive return type (double)

场景:

服务启动正常,接口调用时出现异常。

业务描述:通过用户标识获取用户目前为止的所有投资收益。但测试使用的用户是新注册的用户,无投资金额。


解决:

  1. DEBUG模式跟踪,发现底层mapper.xml 中的 SQL

  2. select sum(invest) from db
  3. 此时 invest 为空 , sum (null) , 赋值给 double ,所以系统提示异常,尝试把一个 null值复制给 double 类型数据

  4. select IFNULL(sum(invest),0) FROM DB
  5. 返回值时进行判断,若为空,则返回0

  6. mapper的返回值,尽量使用包装类

本文出自 “工作常用工具类” 博客,请务必保留此出处http://mingyundezuoan.blog.51cto.com/4012317/1934283

attempted to return null from a method with a primitive return type (double)

原文:http://mingyundezuoan.blog.51cto.com/4012317/1934283

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!