mybatis映射异常:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflect

先说下原因

     Mapper文件中当我们的入参为entity实体,或者map的时候,使用if 参数判断没任何问题。

但是当我们的入参为java.lang.Integer 或者 java.lang.String的时候,这时候就需要注意一些事情了

<select id="findByBatchNo" parameterType="java.lang.String" resultType="java.lang.Integer">
    SELECT
    count(*)
    FROM
    t_sys_batch_withhold t
    <where>
      <if test="batchNo != null">
        t.batch_no = #{batchNo}
      </if>
    </where>
  </select>

或者

<select id="getTrnsctListByLangId" parameterType="java.lang.Integer" resultType="java.lang.Integer">  
    select   
     trnsct_id  
    from  t_trnsct_way_l where   
    <if test="langId != null" >  
       and lang_id = #{langId}  
    </if>  
  </select>

就会报错:

     org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException

解决办法

    

经过验证string可以不加

猜你喜欢

转载自blog.csdn.net/lnn112233/article/details/84847961
今日推荐