Mybatis--更新
来源:互联网 发布:王陆807和语料库 知乎 编辑:程序博客网 时间:2024/06/05 04:00
1.带条件的批量更新对象
<update id="updateEvent" parameterType="java.util.List"><foreach collection="list" item="item" index="index" open="" close="" separator=";">update t_event <set><if test="item.name != null and item.name != ''">name =#{item.name,jdbcType=VARCHAR},</if><if test="item.remark != null and item.remark != ''">remark =#{item.remark,jdbcType=VARCHAR},</if><if test="item.num!= null">num=#{item.num,jdbcType=INTEGER},</if><!--若是允许num=0 在限制条件中需要去掉 num!=''的条件--></set>where eventId = #{item.eventId,jdbcType=VARCHAR} </foreach> </update>
2.表t_event若只有一列 eventId,并只有一条数据,更新
<update id="updateEvent" parameterType="java.lang.Integer">update t_event set eventId = #{eventId,jdbcType=INTEGER}</update>
3.更新event对象一条数据,具有属性name,remark,eventId,level
<update id="update" parameterType="**.Event">update t_event <set><if test="name != null and name != '' ">user_name = #{name,jdbcType=VARCHAR},</if><if test="remark != null and remark != '' ">remark = #{remark,jdbcType=VARCHAR},</if><if test="level != null and level != '' ">level = #{level,jdbcType=VARCHAR},</if></set>where eventId = #{eventId,jdbcType=INTEGER}</update>
阅读全文
0 0
- Mybatis--更新
- Mybatis批量更新
- Mybatis批量更新
- Mybatis批量更新
- mybatis 批量更新
- mybatis 批量更新
- mybatis 批量更新
- Mybatis批量更新
- Mybatis批量更新
- Mybatis分页插件更新
- Mybatis批量更新数据
- Mybatis批量更新
- Mybatis分页插件更新
- mybatis批量更新
- Mybatis分页插件更新
- Mybatis 级联插入更新
- Mysql+Mybatis批量更新
- Mybatis批量更新数据
- 褚时健84岁再成亿万富翁
- JavaScript基础
- MySQL的InnoDB索引原理详解
- 界面编码报错:Page-encoding specified in XML prolog (UTF-8) is different from that specified in
- python学习十(多继承,多态,异常)
- Mybatis--更新
- Balanced Numbers 数位DP+3进制压缩
- 调用百度翻译接口demo(完整ajax请求)
- windows下使用pthread
- 手把手教你Android手机与BLE终端通信--搜索
- 用quartz进行定时任务的开发
- 系统监控工具
- 在进行C#编程时候,有的时候我们需要判断一个字符串是否是数字字符串,我们可以通过以下两种方法来实现。 【方法一】:使用 try{} catch{} 语句。 我们可以在try语句块中试图
- 第 8 章 查找