[mybatis-异常]:BindingException: Mapper method 'CartMapper.testSum attempted to return null from a met
2018-04-25 12:24
1306 查看
异常信息:
org.apache.ibatis.binding.BindingException: Mapper method ‘CartMapper.testSum attempted to return null from a method with a primitive return type (int).
// CartMapper int testSum(Integer userId);
<select id="testSum" resultType="int"> SELECT sum(quantity) FROM mall_cart WHERE user_id = #{userId} </select>
原因:
试图从具有原始返回类型(int)的方法返回null。
数据库函数sum()在找不到记录时, 会返回null
解决方案
<select id="testSum" resultType="int"> SELECT sum(quantity) FROM mall_cart WHERE user_id = #{userId} </select>阅读更多
相关文章推荐
- MyBatis Error:BindingException Mapper method attempted to return null
- 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 -----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).
- 关于attempted to return null from a method with a primitive return type (int).报错解决方案
- delete 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)
- org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method test() on null context object
- org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property
- mybatis中的一个异常:org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to
- org.apache.ibatis.binding.BindingException: Mapper method 'com.zbiti.alarm.dao.AlarmDao.queryTest at
- Android异常 NullPointerException: Attempt to invoke virtual method int java.lang.Integer.intValue()
- mybatis返回int类型报错 return null from a method with a primitive return type (int).
- java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()'
- hadoop2运行MR异常解决-NoSuchMethodException:xxMapper.<init>()
- org.tigris.subversion.javahl.ClientException: Attempted to lock an already-locked dir异常解决方法
- mybatis 异常 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding
- java.lang.NullPointerException: Attempt to invoke virtual method 'void com.hhl.library.FlowTagLayout