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>

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

  • 相关阅读:
    递归判断回文
    从小工到专家阅读笔记1
    建立SQL全文索引提升搜索速度
    数据库SQLServer经验小记
    [转]C#中调用SQL存储过程(带输入输出参数的例子)
    20101124 14:55 全文索引是解决海量数据模糊查询的较好解决办法
    使用SQL Server 2008提供的表分区向导
    千万级SQL Server数据库表分区的实现
    C#调用存储过程简单完整例子
    SQL server 海量数据库的查询优化及分页算法(收藏)
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10349894.html
Copyright © 2011-2022 走看看