zoukankan      html  css  js  c++  java
  • 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>

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

  • 相关阅读:
    php 加入即时推送功能
    Yii GridView::widget
    linux 文件文件夹操作
    一套一般般的前端框架 layui
    supervisor 与 yii定时任务 crontab的使用
    yii 国际化
    如何在Webstorm/Phpstorm中设置连接FTP,并快速进行文件比较,上传下载,同步等操作
    docker搭建lnmp环境
    docker搭建lnmp环境(问题,资料,命令)
    yii2 刷新缓存(刷新模型缓存)
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10349894.html
Copyright © 2011-2022 走看看