Home >Database >Mysql Tutorial >MyBatis插入时候获取自增主键方法

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

WBOY
WBOYOriginal
2016-06-07 17:36:181596browse

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

    Statement:
    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