attempted to return null from a method with a primitive return type (int).
来源:互联网 发布:软件测试基础理论 编辑:程序博客网 时间:2024/05/22 10:34
<select id="getMaxHitEventId" parameterType="string" resultType="int"> select max(app_hitEventID) from hits_tab_app where app_hitV=#{app_hitV}</select>mybatis+mysql查询出来会报如下错误:
attempted to return null from a method with a primitive return type (int).
我的返回值类型为int,但是查询出来的结果有空值,所以会出现如上的异常,以下为解决办法:
1.当查询出来为空时,给赋值一个默认值:
select IFNULL(max(app_hitEventID),0) from hits_tab_app where app_hitV=#{app_hitV}
2.将返回值类型改为Integer,然后由业务代码去进行判断:
<select id="getMaxHitEventId" parameterType="string" resultType="Integer"> select max(app_hitEventID) from hits_tab_app where app_hitV=#{app_hitV}</select>
阅读全文
2 0
- attempted to return null from a method with a primitive return type (int).
- mybatis -----attempted to return null from a method with a primitive return type (int)
- attempted to return null from a method with a primitive return type (int)异常的解决
- 关于attempted to return null from a method with a primitive return type (int).报错解决方案
- MyBatis提示getFundBonus attempted to return null from a method with a primitive return type (double)
- 【java】Mybatis返回int类型为空时报错 attempted to return null from a method with a primitive return type (int)
- mybatis返回int类型报错 return null from a method with a primitive return type (int).
- aop.AopInvocationException: null return value from advice does not match primitive return type for
- Return multiple values from a method
- return confirm Cannot return from outside a function or method
- Return a null reference
- Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
- Null value was assigned to a property of primitive type setter ,hibernate int型数据无法读取 hiberante读int
- Cannot return from outside a function or method
- Cannot return from outside a function or method
- 【解决方法】Cannot return from outside a function or method
- myeclipse10:Cannot return from outside a function or method.
- Cannot return from outside a function or method
- 地方报
- Sublime Text介绍和使用配置
- Condition 理解
- Linux-ARP请求C程序
- BZOJ3631: [JLOI2014]松鼠的新家
- attempted to return null from a method with a primitive return type (int).
- 垂直跑马灯效果
- Android -- is 32-bit instead of 64-bit
- TCP传输中使用AES加密和gizp压缩
- Oracle数据库创建实体对象,在自命名包中定义函数以及返回实体对象数据
- Apache启动时提示the requested operation has failed
- sqlplus下查看执行计划报错
- Java面试题3
- POSIX 线程取消点的 Linux 实现