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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM