mybatis返回int或者Integer类型报错


会报错如下:

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,都有可能出错

例如

	


我用的oracle  利用 nvl()函数 解决问题

	

相关文章:

用 ISNULL(), NVL(), IFNULL() and COALESCE() 函数替换空值



你可能感兴趣的:(mybatis,mybatis)