mybatis之<trim prefix=““ suffix=““ suffixOverrides=““ prefixOverrides=““></trim>的含义

本文详细解析了MyBatis框架中trim标签的使用技巧,包括如何利用prefix, suffix, prefixOverrides和suffixOverrides属性来优化SQL语句生成,避免冗余,提升SQL语句的灵活性和效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


prefix:在trim标签内sql语句加上前缀。
suffix:在trim标签内sql语句加上后缀。
suffixOverrides:指定去除多余的后缀内容,如:suffixOverrides=",",去除trim标签内sql语句多余的后缀","。
prefixOverrides:指定去除多余的前缀内容

insert into fd_program
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null  and id != ''">id,</if>
            <if test="programName != null  and programName != ''">PROGRAM_NAME,</if>
            <if test="programCode != null  and programCode != ''">PROGRAM_CODE,</if>
            <if test="ratioX != null  and ratioX != ''">RATIO_X,</if>
            <if test="ratioY != null  and ratioY != ''">RATIO_Y,</if>
            <if test="timelength != null  and timelength != ''">TIMELENGTH,</if>
            <if test="created != null ">CREATED,</if>
            <if test="createBy != null  and createBy != ''">CREATE_BY,</if>
            <if test="updated != null ">UPDATED,</if>
            <if test="updateBy != null  and updateBy != ''">UPDATE_BY,</if>
            <if test="comments != null  and comments != ''">COMMENTS,</if>
            <if test="tip != null  and tip != ''">TIP,</if>
         </trim>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值