mybatis中parameterType为string和对象的区别

1、parameterType为String时,需要在mapper接口中定义@Param要传入的字符串名
xxMappper.xml

    
    

xxMapper

List tableName(@Param("dynaKey") String dynaKey);

2、parameterType为对象时,因为已经在对象中定义了属性,所以在mapper接口中就不要添加了@Param或者什么标注了


        insert into t_enterprise_base_info (ENTERPRISE_ID, ENTERPRISE_NAME, ENTERPRISE_USCC,
        GD_INFO, HG_CODE, ESTABLISH_DATE,
        REGIST_CAPITAL, ENTERPRISE_ADDRESS, ENTERPRISE_SCOPE,
        LEGAL_NAME, CONTACT_PHONE, IS_INVEST,
        PARK_TYPE, WORKSHOP_POS, WORKSHOP_AREA,
        INDUSTRY_CLASS, INDUSTRY_CATEGORY, TRIAL_TIME,
        INVEST_TIME, PRODUCT_TIME, BUSI_INFO,
        ENTERPRISE_TYPE, REMARK, STATUS,
        OPERATOR, OPERATE_TIME)
        values (#{enterpriseId,jdbcType=VARCHAR}, #{enterpriseName,jdbcType=VARCHAR}, #{enterpriseUscc,jdbcType=VARCHAR},
        #{gdInfo,jdbcType=VARCHAR}, #{hgCode,jdbcType=VARCHAR}, #{establishDate,jdbcType=DATE},
        #{registCapital,jdbcType=DECIMAL}, #{enterpriseAddress,jdbcType=VARCHAR}, #{enterpriseScope,jdbcType=VARCHAR},
        #{legalName,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, #{isInvest,jdbcType=INTEGER},
        #{parkType,jdbcType=INTEGER}, #{workshopPos,jdbcType=VARCHAR}, #{workshopArea,jdbcType=DECIMAL},
        #{industryClass,jdbcType=INTEGER}, #{industryCategory,jdbcType=INTEGER}, #{trialTime,jdbcType=DATE},
        #{investTime,jdbcType=DATE}, #{productTime,jdbcType=DATE}, #{busiInfo,jdbcType=INTEGER},
        #{enterpriseType,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
        #{operator,jdbcType=VARCHAR}, #{operateTime,jdbcType=TIMESTAMP})
    
int insert(EnterpriseBase record);

你可能感兴趣的:(mybatis中parameterType为string和对象的区别)