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>

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

  • 相关阅读:
    QString和char字符串数组之间的转换 (转)
    RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色
    Android学习笔记:TabHost 和 FragmentTabHost
    关于JDNI、JMX
    Oracle中查看所有的表,用户表,列名,主键,外键
    如何对行 表 数据库加锁
    android网络优化
    深入java虚拟机
    马拉拉:被塔利班追杀的女孩
    Oracle---->基本DDL
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10349894.html
Copyright © 2011-2022 走看看