Mybatis-3: BindingException: Parameter 'a' not found. Available parameters are [param1, b] for the case when I use xml query building and one query for several Mapper-methods.

Created on 31 May 2015  路  4Comments  路  Source: mybatis/mybatis-3

mybatis 3.0.0+

public interface Mapper {
  String select(@Param("a") String s);
  String select(@Param("b") Integer i);
}
  <select id="select" parameterType="map" ..>
    SELECT *
    FROM testtable
    <where>    
    <if test="a != null">
        a_field like #{a}   
    </if>
    <if test="b != null">
        b_field > #{b}
    </if>
  </where>
  </select>

I've got for Mapper#select(1) this:

org.apache.ibatis.binding.BindingException: Parameter 'a' not found. Available parameters are [param1, b]

due to this org/apache/ibatis/binding/MapperMethod.java:168
or this /org/apache/ibatis/session/defaults/DefaultSqlSession.java:294

Could u remove this annoing check or make flag to disable it?

Most helpful comment

Hi,

MyBatis does not support method overloading, unfortunately.
The closest solution I can think of is to define the method with two parameters.

public interface Mapper {
  String select(@Param("a") String s, @Param("b") Integer i);
}

All 4 comments

Hi,

MyBatis does not support method overloading, unfortunately.
The closest solution I can think of is to define the method with two parameters.

public interface Mapper {
  String select(@Param("a") String s, @Param("b") Integer i);
}

i defined a trim
<trim prefix="SET" suffixOverrides=","> <if test="couponId != null"> coupon_id = #{couponId,jdbcType=VARCHAR}, </if> <if test="orderId != null"> order_id = #{orderId,jdbcType=VARCHAR}, </if> <if test="telephone != null"> telephone = #{telephone,jdbcType=VARCHAR}, </if> </trim>
now defined a method -> update(@Param("orderId") String orderId)
throw a exceptioin
org.apache.ibatis.binding.BindingException: Parameter 'couponId' not found

i defined a trim
<trim prefix="SET" suffixOverrides=","> <if test="couponId != null"> coupon_id = #{couponId,jdbcType=VARCHAR}, </if> <if test="orderId != null"> order_id = #{orderId,jdbcType=VARCHAR}, </if> <if test="telephone != null"> telephone = #{telephone,jdbcType=VARCHAR}, </if> </trim>
now defined a method -> update(@param("orderId") String orderId)
throw a exceptioin
org.apache.ibatis.binding.BindingException: Parameter 'couponId' not found

I have the same problem, have you solved it?

瑙e喅浜嗗悧

Was this page helpful?
0 / 5 - 0 ratings