插入集合
<insert id="insertList" parameterType="java.util.List">
insert into operation_product_setting_attribute ( create_date, update_date,
merchant_id, product_id, setting_id,
name, attributes, creator,
creator_id)
values
<foreach collection="list" separator="," item="item">
(
#{item.createDate,jdbcType=TIMESTAMP},
#{item.updateDate,jdbcType=TIMESTAMP},
#{item.merchantId,jdbcType=BIGINT},
#{item.productId,jdbcType=BIGINT},
#{item.settingId,jdbcType=BIGINT},
#{item.name,jdbcType=VARCHAR},
#{item.attributes,jdbcType=BIT},
#{item.creator,jdbcType=VARCHAR},
#{item.creatorId,jdbcType=BIGINT}
)
</foreach>
</insert>
插入实体类
<insert id="insertSelective" parameterType="com.hisun.lemon.db.entity.OperationMerchant" useGeneratedKeys="true" keyProperty="id">
insert into operation_merchant
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="createDate != null" >
create_date,
</if>
<if test="updateDate != null" >
update_date,
</if>
<if test="merchantName != null" >
merchant_name,
</if>
<if test="merchantCode != null" >
merchant_code,
</if>
<if test="enabled != null" >
enabled,
</if>
<if test="enableDelete != null" >
enable_delete,
</if>
<if test="company != null" >
company,
</if>
<if test="companyAddress != null" >
company_address,
</if>
<if test="companyDetail != null" >
company_detail,
</if>
<if test="email != null" >
email,
</if>
<if test="mobile != null" >
mobile,
</if>
<if test="creator != null" >
creator,
</if>
<if test="creatorId != null" >
creator_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="createDate != null" >
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateDate != null" >
#{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="merchantName != null" >
#{merchantName,jdbcType=VARCHAR},
</if>
<if test="merchantCode != null" >
#{merchantCode,jdbcType=VARCHAR},
</if>
<if test="enabled != null" >
#{enabled,jdbcType=BIT},
</if>
<if test="enableDelete != null" >
#{enableDelete,jdbcType=BIT},
</if>
<if test="company != null" >
#{company,jdbcType=VARCHAR},
</if>
<if test="companyAddress != null" >
#{companyAddress,jdbcType=VARCHAR},
</if>
<if test="companyDetail != null" >
#{companyDetail,jdbcType=VARCHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="mobile != null" >
#{mobile,jdbcType=VARCHAR},
</if>
<if test="creator != null" >
#{creator,jdbcType=VARCHAR},
</if>
<if test="creatorId != null" >
#{creatorId,jdbcType=BIGINT},
</if>
</trim>
</insert>
更新实体类
<!--更新商户信息-->
<update id="updateByPrimaryKey" parameterType="com.hisun.lemon.db.entity.OperationMerchant" >
update operation_merchant
<set >
<if test="updateDate != null" >
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="merchantName != null" >
merchant_name = #{merchantName,jdbcType=VARCHAR},
</if>
<if test="merchantCode != null" >
merchant_code = #{merchantCode,jdbcType=VARCHAR},
</if>
<if test="enabled != null" >
enabled = #{enabled,jdbcType=BIT},
</if>
<if test="company != null" >
company = #{company,jdbcType=VARCHAR},
</if>
<if test="companyAddress != null" >
company_address = #{companyAddress,jdbcType=VARCHAR},
</if>
<if test="companyDetail != null" >
company_detail = #{companyDetail,jdbcType=VARCHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
<if test="mobile != null" >
mobile = #{mobile,jdbcType=VARCHAR},
</if>
<if test="creator != null" >
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>