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

Mybatis 在 insert 之后想获取自增的主键 id

时间:2018-04-19 11:53:38      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:into   int   gis   htm   tis   get   col   property   html   

<insert id="add"
        useGeneratedKeys="true" keyColumn="id" keyProperty="id"
        parameterType="user">
    INSERT INTO `user` (`name`,sex,register_ts) VALUES (#{name},#{sex},#{registerTs})
</insert>

  返回的插入成功的行数;自增id直接映射到你的对象里了,直接输出 xxx.getId()就可以了

Mybatis 在 insert 之后想获取自增的主键 id

标签:into   int   gis   htm   tis   get   col   property   html   

原文地址:https://www.cnblogs.com/pangguoming/p/8880735.html

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