SpringBoot+Mybatis 实现长字符串保存和更新

数据库字段,写成长字符

插入xml,注意两个点,否则会报错

1、长字符串字段不能写if判断:<if test="name != null and name != ''">

2、插入的时候做字符串转码:<![CDATA[#{fileCode}]]>

<insert id="insert" parameterType="com.java.core.entity.master.GenTemplateFile" useGeneratedKeys="true"
            keyProperty="id">
        insert into gen_template_file(
        <if test="templateId != null and templateId != ''">template_id,</if>
        <if test="name != null and name != ''">name,</if>
        file_code,
        <if test="orderNumber != null and orderNumber != 0">order_number,</if>
        <if test="create_by != null and create_by != ''">create_by,</if>
        create_time
        )values(
        <if test="templateId != null and templateId != 0">#{templateId},</if>
        <if test="name != null and name != 0">#{name},</if>
        <![CDATA[#{fileCode}]]>,
        <if test="orderNumber != null and orderNumber != ''">#{orderNumber},</if>
        <if test="create_by != null and create_by != ''">#{create_by},</if>
        sysdate()
        )
    </insert>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值