标签:HERE 数据 name com insert ram int product rod
1.mybatis更新一条数据时,如果某字段为空,则不更新它,使用默认值?
<update id="updateProduct" parameterType="Product" > update product_ <set> <if test="name != null">name=#{name},</if> <if test="price != null">price=#{price}</if> </set> where id=#{id} </update>
2.mybatis如何插入一个list类型的记录?
<insert id="addItem" parameterType="java.util.List"> insert into product_ ( id, itemName, number, remark )
values
<foreach collection="list" item="item" index= "index" separator =",">
( #{item.id}, #{item.itemName}, #{item.number}, #{item.remark} )
</foreach>
</insert>
参考:https://www.cnblogs.com/ustc-anmin/p/10480020.html
标签:HERE 数据 name com insert ram int product rod
原文地址:https://www.cnblogs.com/ustc-anmin/p/11904379.html