Mybatis的dao层传递单参出现的问题

通常情况下,mybatis传递单参可以直接传,不需要向多参一样加注解、设置接参名或者利用map那样麻烦,但遇到带if的sql语句

<select id="selectAll" resultMap="BaseResultMap" parameterType="Integer">
      select <include refid="Base_Column_List"/> from tb_cj
      <where>
          <if test="type!=null">
              cj_type=#{type}
          </if>
      </where>

这个if语句的条件似乎不支持type的自动解析,会报错,目前只能加注解或将type改为 _parameter 的方式:test中用 _parameter,sql语句用#{_parameter}

posted @ 2019-09-16 11:47  森罗的灵峰  阅读(199)  评论(0编辑  收藏  举报