您的位置:首页 > 运维架构 > Apache

Mybatis报错 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding

2018-01-22 16:57 831 查看
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 != ''">

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Mybatis Orcale
相关文章推荐