开发者社区 问答 正文

对可能为null的值,使用jdbcType=VARCHAR, 为什么还是会报错??报错


org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch_item_0' not found. Available parameters are [list]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)

这是错误信息,

我写的sql里面可能为null的项是这样处理的

#{item.CountPerson,jdbcType=INTEGER}




展开
收起
爱吃鱼的程序员 2020-06-10 13:26:54 1308 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
    jdbcType是为了处理值类型歧义的,不只是空的问题,一楼的办法是空值与特定值判断最常用的方式

    可能为空加判断 ,例如:

    <iftest="item.CountPerson!=nullanditem.CountPerson!=''">
    CountPerson =#{item.CountPerson}
    </if>

     推荐 http://git.oschina.net/juapk/mybatis-plus    mybatis增强工具包,简化CURD批量操作,分页操作。


    这个是写在foreach标签里面的,不好用if jdbcType可以直接写在sql语句中吗?可以
    2020-06-10 13:27:12
    赞同 展开评论
问答分类:
问答标签:
问答地址: