title: Mybatis-Error: Could not set parameters for mapping
body: <p>I created a sql query as follows</p>
  
  <pre><code>&lt;select id="getReservationByConditions" resultMap="record"&gt;
      SELECT *
      FROM (reservation_record r1 LEFT JOIN real_duty_time r2 ON r1.rdt_id = r2.rdt_id) LEFT JOIN  consultant c1 ON r2.con_id = c1.con_id
      WHERE r1.stu_name LIKE '%${stuName}%' AND c1.con_name LIKE '%#{consultName}%'
      &lt;if test="beginDate != null"&gt;
          AND r2.rdt_date &amp;gt;= #{beginDate,jdbcType=VARCHAR}
      &lt;/if&gt;
      &lt;if test="endDate != null"&gt;
          AND r2.rdt_date &amp;lt;= #{endDate,jdbcType=VARCHAR}
      &lt;/if&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>And the value of the parameters are </p>
  
  <pre><code>String stuName = "nike";
  String beginDate = "2018-03-01";
  String endDate = "2018-06-01";
  String consultName = "";
  </code></pre>
  
  <p>And the errors are</p>
  
  <pre><code>org.mybatis.spring.MyBatisSystemException:
  nested exception is org.apache.ibatis.type.TypeException:
  Could not set parameters for mapping: ParameterMapping{property='endDate', mode=IN, javaType=class java.lang.Object, jdbcType=VARCHAR, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. 
  
  Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #3 with JdbcType VARCHAR . 
  Try setting a different JdbcType for this parameter or a different configuration property. 
  
  Cause: org.apache.ibatis.type.TypeException:
  Error setting non null for parameter #3 with JdbcType VARCHAR .
  Try setting a different JdbcType for this parameter or a different configuration property.
  
  Cause: java.sql.SQLException: Parameter index out of range (3 &gt; number of parameters, which is 2).
  </code></pre>
  
  <p>The parameter "endDate" is exactly String type,why  "javaType=class java.lang.Object".</p>
  
  <p>How do I fix it?</p>
  
  <p>Thank you for help.</p>
  
  <hr>
  
  <p>The java mapper code is as follows:</p>
  
  <pre><code>List&lt;ReservationRecord&gt; getReservationByConditions(@Param("stuName")String stuName, @Param("beginDate")String beginDate, @Param("endDate")String endDate, @Param("consultName")String consultName);
  </code></pre>
  
  <hr>
  
  <p>well.I know what's wrong with my code. The '%#{consultName}%' in sql query should be '%${consultName}%'. I changed it and it works fine. It is a really ridiculous problem. I think I should be more careful.</p>