mybatis主键返回语句 使用方法,就是实体类.getid即可拿到返回的id

mybatis主键返回语句 使用方法,就是实体类.getid即可拿到返回的id

 

<insert id="insertSelective" parameterType="com.o2o.Content"
        useGeneratedKeys="true" keyProperty="id">
        insert into notice_ncontent
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="vid != null">
                vid,
            </if>
            <if test="ntype != null">
                ntype,
            </if>
            <if test="canentry != null">
                canentry,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="ispush != null">
                ispush,
            </if>
            <if test="entrycount != null">
                entrycount,
            </if>
            <if test="isvalid != null">
                isvalid,
            </if>
            <if test="content != null">
                content,
            </if>
            <if test="ctime != null">
                ctime,
            </if>
            <if test="cuserid != null">
                cuser,
            </if>
            <if test="stick != null">
                stick,
            </if>
            <if test="limitcount != null">
                limitcount,
            </if>
            <if test="description != null">
                description,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="vid != null">
                #{vid,jdbcType=INTEGER},
            </if>
            <if test="ntype != null">
                #{ntype,jdbcType=TINYINT},
            </if>
            <if test="canentry != null">
                #{canentry,jdbcType=TINYINT},
            </if>
            <if test="title != null">
                #{title,jdbcType=VARCHAR},
            </if>
            <if test="ispush != null">
                #{ispush,jdbcType=TINYINT},
            </if>
            <if test="entrycount != null">
                #{entrycount,jdbcType=INTEGER},
            </if>
            <if test="isvalid != null">
                #{isvalid,jdbcType=INTEGER},
            </if>
            <if test="content != null">
                #{content,jdbcType=LONGVARCHAR},
            </if>
            <if test="ctime != null">
                #{ctime,jdbcType=BIGINT},
            </if>
            <if test="cuserid != null">
                #{cuserid,jdbcType=INTEGER},
            </if>
            <if test="stick != null">
                #{stick,jdbcType=INTEGER},
            </if>
            <if test="limitcount != null">
                #{limitcount,jdbcType=INTEGER},
            </if>
            <if test="description != null">
                #{description,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

通过上叙就可以获取自动主键,但是一般开发中都是自己生产主键进行开发,这个是利用数据库自增主键来进行的

posted @ 2019-02-03 11:14 动手的程序员 阅读( ...) 评论( ...) 编辑 收藏
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值