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>
  • 相关阅读:
    GEF: 图形拖拽处理
    【矩阵快速幂】bzoj1297 [SCOI2009]迷路
    【扩展欧几里得】NOIP2012同余方程
    【高精度乘法】NOIP2003麦森数
    【数论·错位排列】bzoj4517 排列计数
    【数论】Lucas
    【NOIP2012】疫情传递
    【NOIP2012】旅行计划
    【Manacher算法】求最长回文串的优秀算法
    【Tarjan】洛谷P3379 Tarjan求LCA
  • 原文地址:https://www.cnblogs.com/person008/p/11726464.html
Copyright © 2011-2022 走看看