来源:深圳沃龙软件开发公司 2017-05-24
mybatis sql中查询类型为double的字段,返回null的异常,
org.apache.ibatis.binding.BindingException: to return null from a method with a primitive return type (double)
mybatis 查询如下,当 可以查到有跟follower_id 值相关的话,就没有问题
<select id="sumFollowerSubgroupSalesMoney" resultType="java.lang.Double"
parameterType="java.lang.Integer">
select
sum(sales_money)
from follower_subgroup_info
where 1=1
<if test="followerId != null" >
and follower_id = #{followerId,jdbcType=INTEGER}
</if>
</select>
可是当没有查到记录,返回null的时候,就会抛to return null from a method with a primitive return type (double) 这个异常,
解决办法如下:
<select id="sumFollowerSubgroupSalesMoney" resultType="java.lang.Double"
parameterType="java.lang.Integer">
select
IFNULL(sum(sales_money),0) as salesMoney
from follower_subgroup_info
where 1=1
<if test="followerId != null" >
and follower_id = #{followerId,jdbcType=INTEGER}
</if>
</select>
本内容皆为 深圳沃龙软件开发公司 原创
如需转载,请注明文章出处和来源网址:http://www.wooolong.com/blog/13.html
?a href=HHtp://cialis.lat/discover-the-best-prices-for-cialis?buy cialis online overnight shipping?/a? According to the 2013 NCCN guidelines for breast cancer, breast cancer patients who are hormone receptor positive were recommended to undergo endocrine therapy for at least 5 years after the completion of surgery and chemotherapy 23 24
发表评论