zoukankan      html  css  js  c++  java
  • Mybatis报错 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'parentCode' not found. Available parameters are [0, 1, param1, param2]

      orcal数据库使用mybatis接收参数,如果传的是多个参数,需要使用#{0},#{1},。。。等代替具体参数名,0 代表第一个参数,1 代表第二个参数,以此类推。

      错误语句:

    <select id = "findNameByCode" resultMap="resultMap">
    select
    name,code
    from
    table
    <where>
    code = #{code} and name = #{name}
    </where>
    </select>

      正确语句:

    <select id = "findNameByCode" resultMap="resultMap">
    select
    name,code
    from
    table
    <where>
    code = #{0} and name = #{1}
    </where>
    </select>
    如果需要对参数使用<if>进行判断的话,需要在XXXDAO.java接口层使用@Param注解 : void get(@Param("value") String name);
      注: @Param中的参数需要跟 <if test=""> 中的判读参数一致, eg : 使用上面的DAO接口,Mapper中判断 : <if test="value != null and value != ''">

     

  • 相关阅读:
    使用pca/lda降维
    交叉验证
    各模型选择及工作流程
    岭回归
    线性回归
    K-临近算法(KNN)
    django中的中间件
    django中form组件
    javascript中的词法分析
    Django之Model操作
  • 原文地址:https://www.cnblogs.com/gczmn/p/7475218.html
Copyright © 2011-2022 走看看