<insert id="insert" parameterType="com.lls.model.Employee">

<!-- selectKey 标签表示子查询中主键的提取问题
 resultType表示返回主键的数据类型
keyProperty表示将属性设置到某个列中 此处为id
order="AFTER表示在插入语句之后执行
resultType="long"表示返回值得类型为long类型
-->

     <selectKey resultType="long" order="AFTER" keyProperty="id">
           SELECT LAST_INSERT_ID() AS ID
     </selectKey>

insert into t_employee (ID, EmployeeName, Position,
Salary, Tel, DepartmentID
)
values (#{id,jdbcType=INTEGER}, #{employeename,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR},
#{salary,jdbcType=DOUBLE}, #{tel,jdbcType=VARCHAR}, #{departmentid,jdbcType=INTEGER}
)

mybatis中:selectKey返回最近插入记录的id的更多相关文章

  1. 数据库返回刚插入记录的ID

    --创建数据库和表create database MyDataBaseuse MyDataBase create table mytable(id int identity(1,1),name var ...

  2. MyBatis 插入时返回刚插入记录的主键值

    MyBatis 插入时返回刚插入记录的主键值 一.要求: 1.数据库表中的主键是自增长的,如:id: 2.获取刚刚插入的记录的id值: 二.源代码: 1.User.java package cn.co ...

  3. MyBatis 获取插入记录的 id

    现在的项目改用 Guns 了,也是一个很不错的框架,用起来也感觉很不错,上手也挺方便的.毕竟对于只是应用层面的知识,也基本上就是看看手册,熟悉熟悉就可以轻松上手了.如果是想要深入,或者刨根问底,那么就 ...

  4. SSM获取表单数据插入数据库并返回插入记录的ID值

    以下指示插入操作以及获取记录值的ID的部分操作代码!!! 首先是简单的表单实现 <%@ page language="java" contentType="text ...

  5. ThinkPHP框架返回插入记录的id号

    ThinkPHP返回插入记录的id号 $Form->create()) $result = $Form->add(); 在执行上述语句后,若存在auto_increment字段,则可以使用 ...

  6. SQL 返回刚插入数据的ID

    处理方法在某个字段上加上identity id int identity(1,1), 创建标识的三种方法及比较: SQL Server 2000中,有三个比较类似的功能:他们分别是:SCOPE_IDE ...

  7. 使用SQLServer2005插入一条数据时返回当前插入数据的ID

    使用SQLServer2005插入一条数据时返回当前插入数据的ID 在执行完插入后 再执行 select @@identity from users 就OK 就是刚才插入的那行的 ID了 补充: @@ ...

  8. MyBatis插入数据之后返回插入记录的id

    MyBatis插入数据的时候,返回该记录的id<insert id="insert" keyProperty="id" useGeneratedKeys= ...

  9. 用mybatis中的insert方法插入数据,返回值为1,但数据库却没有数据

    刚才在写东西的时候,用mybatis中的 <insert id="add" parameterType="cn.entity.Computer"> ...

随机推荐

  1. FFmpeg命令行工具学习(三):媒体文件转换工具ffmpeg

    一.简述 ffmpeg是一个非常强大的工具,它可以转换任何格式的媒体文件,并且还可以用自己的AudioFilter以及VideoFilter进行处理和编辑.有了它,我们就可以对媒体文件做很多我们想做的 ...

  2. WordPress外链新窗口打开并使用php页面go跳转

    之前浏览别人的博客网站,打开外链时会有一个等待时间的代码,虽然不知道有什么用,但觉的挺有档次..今天正好看到教程,就自己也加上了,就复制粘贴些代码可以了 首先创建一个php文件,名字随便,如果你不想改 ...

  3. [Swift]LeetCode620. 有趣的电影 | Not Boring Movies

    SQL架构 Create table If Not Exists cinema (id ), description varchar(), rating , )) Truncate table cin ...

  4. [Swift]LeetCode756. 金字塔转换矩阵 | Pyramid Transition Matrix

    We are stacking blocks to form a pyramid. Each block has a color which is a one letter string, like ...

  5. [Swift]LeetCode802. 找到最终的安全状态 | Find Eventual Safe States

    In a directed graph, we start at some node and every turn, walk along a directed edge of the graph.  ...

  6. [Swift]LeetCode949. 给定数字能组成的最大时间 | Largest Time for Given Digits

    Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour t ...

  7. [Swift]LeetCode972.相等的有理数 | Equal Rational Numbers

    Given two strings S and T, each of which represents a non-negative rational number, return True if a ...

  8. 优化之Normalizer组件

    Normalizer会产生记录,尽可能的将Normalizer组件靠近Target ---------------------------------------------------------- ...

  9. java程序员的NodeJS初识篇

    摘要 作为一个一直用java来写后端的程序员用NodeJS来写后台,实在不是很爽.这里记下这两个月的NodeJS学习所遇之坑,与java转NodeJS的同仁共勉.学习时间不长,若有理解错误,望指正. ...

  10. Python内置函数(26)——globals

    英文文档: globals() Return a dictionary representing the current global symbol table. This is always the ...