mybatis返回int或者Integer类型报错
来源:互联网 发布:中国光伏行业协会数据 编辑:程序博客网 时间:2024/06/05 04:26
会报错如下:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'com.bill.springMybatis.dao.UserDao.getUserIdByName attempted to return null from a method with a primitive return type (int).
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:894)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
返回类型设置为封装类型Integer或者基本类型int,都有可能出错
例如
<select id="queryPaySum" resultType="java.lang.Integer" parameterType="map" >select sum(p.CASH_FEE) from PAY_INFO pwhere 1=1 and p.TRADE_RESULT_CODE = #{traderesultcode}</select>
我用的oracle 利用 nvl()函数 解决问题
<select id="queryPaySum" resultType="java.lang.Integer" parameterType="map" >select nvl(sum(p.CASH_FEE), 0) from PAY_INFO pwhere 1=1 and p.TRADE_RESULT_CODE = #{traderesultcode}</select>
相关文章:
用 ISNULL(), NVL(), IFNULL() and COALESCE() 函数替换空值
- mybatis返回int或者Integer类型报错
- mybatis返回int类型报错
- myBatis 返回 int 类型时,报 null 异常
- mybatis返回int类型报错 return null from a method with a primitive return type (int).
- 使用MyBatis查询 返回类型为int,但是当查询结果为空NULL,报异常的解决方法
- integer(int) 整数类型
- myBatis返回integer值
- Mybatis 查询int类型数据,返回记录条数为0时报错问题解决
- inet_ntoa报错显示返回int
- int与Integer类型关系
- 子函数返回类型int
- 如果不空null并且不是空字符串才去修改这个值,但这样写只能针对字符串(String)类型,如果是Integer类型的话就会有问题了。 int i = 0; i!=''。 mybatis中会返回tr
- mybatis连接mysql数据库 tinyint为boolean类型,怎样使其返回类型为integer
- mybatis返回类型string,或者对象,均可用list<string>或者,list<对象>来接收
- 【java】Mybatis返回int类型为空时报错 attempted to return null from a method with a primitive return type (int)
- mybatis在使用integer类型
- mybatis返回类型
- MyBatis之返回类型
- BP 算法之一种直观的解释
- C#开发微信公众平台(附Demo)
- 图的建立、广度优先遍历和深度优先遍历
- Android中ImageView的scaleType属性详解
- Linux下Tomcat的启动、关闭、杀死进程
- mybatis返回int或者Integer类型报错
- 使用VM安装Mac OS
- J2EE进阶(十六)Hibernate 中getHibernateTemplate()方法使用
- MVC封装(九)composer加载
- LintCode 180-二进制表示
- 【数据结构】图的遍历方法 深度优先遍历和广度优先遍历
- Hubilder调试php
- TCP、UDP、IP 协议分析
- Android学习【Android内核编译流程和错误笔记】