首页 > 解决方案 > 未找到参数“updateBy”。可用参数为 [0, createBy, param1, param2]

问题描述

我想执行一个只有一个参数的“SELECT”命令:createBy(实际上我不知道dao.xml是如何管理第一个泛型参数的,所以在我看来,只有一个参数),为什么Mybatis 抛出异常:找不到参数'updateBy'?使用 if 条件:<if test="updateBy != null and updateBy.id != null and updateBy.id != ''"> dao.java 是:

public List<T> findList(T entity, @Param("createBy") User createBy);

而dao.xml中的select sql为:

<select id="findList" resultType="ChenminIndicator">
    SELECT 
        <include refid="chenminIndicatorColumns"/>
    FROM chenmin_indicator a
    <include refid="chenminIndicatorJoins"/>
    <where>
        a.del_flag = #{DEL_FLAG_NORMAL}
        <if test="createBy != null and createBy.id != null and createBy.id != ''">
            AND a.create_by = #{createBy.id}
        </if>
        <if test="updateBy != null and updateBy.id != null and updateBy.id != ''">
            AND a.update_by = #{updateBy.id}
        </if>

    </where>
    <choose>
        <when test="page !=null and page.orderBy != null and page.orderBy != ''">
            ORDER BY ${page.orderBy}
        </when>
        <otherwise>
            ORDER BY a.update_date DESC
        </otherwise>
    </choose>
</select>

标签: mybatis

解决方案


推荐阅读