码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis学习笔记2

时间:2016-09-08 23:02:20      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

1、获得插入语句执行之后的自增主键

<insert id="insertUser" parameterType="com.mybatis.po.User">
        <selectKey keyProperty="id" order="AFTER"  resultType="java.lang.Integer">
        select LAST_INSERT_ID()
        </selectKey>
        insert into user(id,username,birthday,sex,address) values(#{id},#{username},#{birthday},#{sex},#{address})
    </insert>

2、获得插入语句执行之前的非自增主键

<insert id="insertUser" parameterType="com.mybatis.po.User">
    insert into user(id,username,birthday,sex,address) values(#{id},#{username},#{birthday},#{sex},#{address})
 <selectKey keyProperty="id" order="AFTER"  resultType="java.lang.Integer">
    select uuid()
    </selectKey>
    </insert>

 

mybatis学习笔记2

标签:

原文地址:http://www.cnblogs.com/mrluotong/p/5854687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!