mybatis 如何通过resultMap 返回long

网友投稿 785 2022-12-26

mybatis 如何通过resultMap 返回long

mybatis 如何通过resultMap 返回long

mybatis resultMap 返回long

mybatis long 类型返回为null报异常

Mapper method 'com.mpn.dao.TWeatherMapper.avgWeatherTemperature attempted to return null from a method with a primitive return type (long).

SELECT IFNULL(AVG(WeatherTemperature),0) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,jdbcType=VARCHAR};

SELECT SUM(WeatherTemperature) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,jdbcType=VARCHAR};

SELECT IFNULL(AVG(WeatherHumidity),0) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,jdbcType=VARCHAR};

由于返回为空long中没有此类型所以抛异常,改为

SELECT IFNULL(AVG(WeatherTemperature),0) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,http://jdbcType=VARCHAR};

SELECT IFNULL(SUM(WeatherTemperature),0) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,jdbcType=VARCHAR};

SELECT IFNULL(AVG(WeatherHumidity),0) AS OrderAverage FROM t_weather WHERE WeatherDate= #{date,jdbcType=VARCHAR};

用IFNULL来进行判断

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序拉起app(微信小程序拉起APP)
下一篇:mybatis如何返回某列的最大值
相关文章

 发表评论

暂时没有评论,来抢沙发吧~