zoukankan      html  css  js  c++  java
  • mysql默认值不起作用

    记录一下,mysql默认值起作用了,只是insert 的时候字段没有判断null或者空,导致默认值被覆盖,改为如下添加

    <insert id="save" parameterType="com.bootdo.stock.domain.GoodsManageDO" useGeneratedKeys="true" keyProperty="goodsManageId">
            insert into stock_goods_manage
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="deptId != null  and deptId != ''  ">dept_id,</if>
                <if test="semesterId != null  and semesterId != ''  ">semester_id,</if>
                <if test="inTotalNum != null  and inTotalNum != ''  ">in_total_num,</if>
                <if test="outTotalNum != null  and outTotalNum != ''  ">out_total_num,</if>
                <if test="planInNum != null  and planInNum != ''  ">plan_in_num,</if>
                <if test="planOutNum != null  and planOutNum != ''  ">plan_out_num,</if>
                <if test="temporaryInNum != null  and temporaryInNum != ''  ">temporary_in_num,</if>
                <if test="temporaryOutNum != null  and temporaryOutNum != ''  ">temporary_out_num,</if>
                <if test="checkTotalNum != null  and checkTotalNum != ''  ">check_total_num,</if>
                <if test="totalNum != null  and totalNum != ''  ">total_num,</if>
                <if test="startSemesterNum != null  and startSemesterNum != ''  ">start_semester_num,</if>
                <if test="endSemesterNum != null  and endSemesterNum != ''  ">end_semester_num,</if>
                <if test="goodsId != null  and goodsId != ''  ">goods_id,</if>
                <if test="goodsCode != null  and goodsCode != ''  ">goods_code,</if>
                <if test="goodsName != null  and goodsName != ''  ">goods_name,</if>
                <if test="goodsAbb != null  and goodsAbb != ''  ">goods_abb,</if>
                <if test="model != null  and model != ''  ">model,</if>
                <if test="unit != null  and unit != ''  ">unit,</if>
                <if test="kind != null  and kind != ''  ">kind,</if>
                <if test="price != null  and price != ''  ">price,</if>
                <if test="remark != null  and remark != ''  ">remark</if>
            </trim>
            <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="deptId != null  and deptId != ''  ">#{deptId},</if>
                <if test="semesterId != null  and semesterId != ''  ">#{semesterId},</if>
                <if test="inTotalNum != null  and inTotalNum != ''  ">#{inTotalNum},</if>
                <if test="outTotalNum != null  and outTotalNum != ''  ">#{outTotalNum},</if>
                <if test="planInNum != null  and planInNum != ''  ">#{planInNum},</if>
                <if test="planOutNum != null  and planOutNum != ''  ">#{planOutNum},</if>
                <if test="temporaryInNum != null  and temporaryInNum != ''  ">#{temporaryInNum},</if>
                <if test="temporaryOutNum != null  and temporaryOutNum != ''  ">#{temporaryOutNum},</if>
                <if test="checkTotalNum != null  and checkTotalNum != ''  ">#{checkTotalNum},</if>
                <if test="totalNum != null  and totalNum != ''  ">#{totalNum},</if>
                <if test="startSemesterNum != null  and startSemesterNum != ''  ">#{startSemesterNum},</if>
                <if test="endSemesterNum != null  and endSemesterNum != ''  ">#{endSemesterNum},</if>
                <if test="goodsId != null  and goodsId != ''  ">#{goodsId},</if>
                <if test="goodsCode != null  and goodsCode != ''  ">#{goodsCode},</if>
                <if test="goodsName != null  and goodsName != ''  ">#{goodsName},</if>
                <if test="goodsAbb != null  and goodsAbb != ''  ">#{goodsAbb},</if>
                <if test="model != null  and model != ''  ">#{model},</if>
                <if test="unit != null  and unit != ''  ">#{unit},</if>
                <if test="kind != null  and kind != ''  ">#{kind},</if>
                <if test="price != null  and price != ''  ">#{price},</if>
                <if test="remark != null  and remark != ''  ">#{remark}</if>
            </trim>
        </insert>
  • 相关阅读:
    bzoj [Scoi2016]美味
    bzoj2200[Usaco2011 Jan]道路和航线
    bzoj3196 二逼平衡树 树套树(线段树套Treap)
    BZOJ3295 动态逆序对(树状数组套线段树)
    hdu 4819 Mosaic 树套树 模板
    bzoj2843 极地旅行社 LCT
    bzoj3874&2832 [Ahoi2014]宅男计划 模拟退火,三分
    bzoj3609 [Heoi2014]人人尽说江南好 博弈
    find命令进阶用法(一)
    find按照文件大小查找
  • 原文地址:https://www.cnblogs.com/person008/p/11726464.html
Copyright © 2011-2022 走看看