The role of the Mybatis @Param annotation

1. The @Param annotation is used to name the parameters.
If the passed parameter types are basic data types and String types, you need to use this annotation to
step on the pit. If you do not use the @Param annotation, the parameters cannot be passed. Although the names are the same, Param It cannot be omitted
here is to rename the parameters in the interface to the names in #{}

List<EditCheckIdToFuncName> getEditCheckIdToFunctionNameByMap(@Param("studyId") String studyId, @Param("ecrfDraftId") String ecrfDraftId);
<resultMap id="funcMap" type="com.XXXXXX.app.edc.business.draft.excel.EditCheckIdToFuncName">
        <id column="edit_check_id" jdbcType="VARCHAR" property="editCheckId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="function_type" jdbcType="INTEGER" property="functionType"/>
    </resultMap>
    <select id="getEditCheckIdToFunctionNameByMap" resultMap="funcMap">
        select a.edit_check_id,a.name,a.function_type from
            (select p.edit_check_id,p.study_id,p.ecrf_draft_id,p.ecrf_version_id,p.ecrf_sub_version_id, c.name ,c.function_type
             from edc_crf_logical_action_parameter p
                      left join edc_customized_function c
                                on  c.id = p.function_id) a
        where a.function_type = 2
          and a.study_id = #{studyId}
          and a.ecrf_draft_id = #{ecrfDraftId}
    </select>

2. When this annotation is not used: a JAVABEAN is passed

Guess you like

Origin blog.csdn.net/kunAUGUST/article/details/120345474