Home > Database > Mysql Tutorial > body text

MyBatis插入时候获取自增主键方法

WBOY
Release: 2016-06-07 17:36:18
Original
1575 people have browsed it

MyBatis 3.2.6插入时候获取自增主键方法有二 以MySQL5.5为例: 方法1: lt;insert id=insert parameterType=Person use

MyBatis插入时候获取自增主键方法

[日期:2014-03-27] 来源:Linux社区  作者:lavasoft [字体:]

MyBatis 3.2.6插入时候获取自增主键方法有二

以MySQL5.5为例:

方法1:

   
        insert into person(name,pswd) values(#{name},#{pswd})
   

方法2:

   
       
            select LAST_INSERT_ID()
       

        insert into person(name,pswd) values(#{name},#{pswd})
   

插入前实体id属性为0;

插入后实体id属性为保存后自增的id;

linux

  • 0
  • ORA-20079: full resync from primary database is not done

    ORA-27300,ORA-27301,ORA-27302

    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!