mybatis新增处理逗号
来源:互联网 发布:初学者模拟炒股软件 编辑:程序博客网 时间:2024/06/07 13:35
我们有时候考虑到代码复用,新增的时候希望可以选择字段,就需要对字段进行判断,但是字段后面会跟上逗号,如果是最后一个字段为空,那么会多一个逗号。代码片段如下:
<if test="phone != null and phone != ''">
#{phone},
</if>
<if test="idCard != null and idCard != ''">
#{idCard}
</if>
如果idCard为空,#{phone}的后面就会多一个逗号。我们可以用一个<trim suffixOverrides=","></trim>标签来处理这种情况。完整代码如下:
<!--新增广告 -->
<insert id="addAd" parameterType="com.xddManagement.entity.xdd.XddAdposition">
insert into xdd_adposition (<trim suffixOverrides=",">
<if test="advertisingId != null and advertisingId != ''">
advertisingId,
</if>
<if test="advertisingNo != null and advertisingNo != ''">
advertisingNo,
</if>
<if test="content != null and content != ''">
content,
</if>
<if test="type != null and type != ''">
type,
</if>
<if test="period != null and period != ''">
period,
</if>
<if test="status != null and status != ''">
status,
</if>
<if test="createTime != null and createTime != ''">
createTime,
</if>
<if test="putTime != null and putTime != ''">
putTime,
</if>
<if test="outTime != null and outTime != ''">
outTime,
</if>
<if test="expireTime != null and expireTime != ''">
expireTime,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="title != null and title != ''">
title,
</if>
<if test="compName != null and compName != ''">
compName,
</if>
<if test="compAddress != null and compAddress != ''">
compAddress,
</if>
<if test="person != null and person != ''">
person,
</if>
<if test="phone != null and phone != ''">
phone,
</if>
<if test="idCard != null and idCard != ''">
idCard
</if></trim>
)values(<trim suffixOverrides=",">
<if test="advertisingId != null and advertisingId != ''">
#{advertisingId},
</if>
<if test="advertisingNo != null and advertisingNo != ''">
#{advertisingNo},
</if>
<if test="content != null and content != ''">
#{content},
</if>
<if test="type != null and type != ''">
#{type},
</if>
<if test="period != null and period != ''">
#{period},
</if>
<if test="status != null and status != ''">
#{status},
</if>
<if test="createTime != null and createTime != ''">
#{createTime},
</if>
<if test="putTime != null and putTime != ''">
#{putTime},
</if>
<if test="outTime != null and outTime != ''">
#{outTime},
</if>
<if test="expireTime != null and expireTime != ''">
#{expireTime},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="title != null and title != ''">
#{title},
</if>
<if test="compName != null and compName != ''">
#{compName},
</if>
<if test="compAddress != null and compAddress != ''">
#{compAddress},
</if>
<if test="person != null and person != ''">
#{person},
</if>
<if test="phone != null and phone != ''">
#{phone},
</if>
<if test="idCard != null and idCard != ''">
#{idCard}
</if></trim>)
</insert>
- mybatis新增处理逗号
- mybatis批量新增系列之类型处理
- Mybatis-新增
- mybatis foreach in查询语句 关于逗号 空值处理问题
- mybatis 批量新增
- mybatis的批量新增
- MyBatis批量新增、更新
- mybatis的批量新增
- MyBatis的批量新增
- mybatis的批量新增
- mybatis 新增判断空
- mybatis的批量新增
- Mybatis批量新增,修改
- Mybatis批量新增
- mybatis insert新增语句
- mybatis新增(三)
- asp formatNumber处理逗号问题
- JS货币逗号的处理
- 【深度解析】FPGA四大设计要点
- ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 G题Bounce
- UVA 10336 Rank the Languages
- JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- 单链表与双向链表
- mybatis新增处理逗号
- extern与头文件(*.h)的区别和联系
- 《C语言程序设计教程》(一)
- 神经机器翻译(Neural Machine Translation)系列教程
- jquery-ui实现bootstrap的modal拖拽功能,弹窗头部拖拽
- CSDN-markdown编辑器用法
- 合并两个排序的链表
- matlab画图程序整理
- 数据库索引的实现原理