使用mybatis, 如何获取刚插入数据的id
2015-08-04 11:48
369 查看
做项目时,使用mysql, springMvc框架,遇到需要刚插入数据库中的数据的ID的问题。
解决方案,只需要在映射文件中,<input>加入以下属性:
useGeneratedKeys="true" keyProperty="id"
例如:<insert id="insert" parameterType="com.*.article.*.*" useGeneratedKeys="true" keyProperty="id">
它的返回值,仍旧是num=1,但是,insert所使用那个的article中,Id已经被更新!
解决方案,只需要在映射文件中,<input>加入以下属性:
useGeneratedKeys="true" keyProperty="id"
例如:<insert id="insert" parameterType="com.*.article.*.*" useGeneratedKeys="true" keyProperty="id">
它的返回值,仍旧是num=1,但是,insert所使用那个的article中,Id已经被更新!
相关文章推荐
- Android MediaPlayer与Http Proxy结合之基础篇
- OpenCV Cut Image via ROI 根据兴趣区域剪裁图片
- 江湖恩仇录之PHP程序CPU高占用优化经历分享
- java操作properties文件
- MYSQL问题解决方案:Access denied for user 'root'@'localhost' (using password:YES)
- win7下debug native 环境搭建
- Android通过Xutils注解实例化以及事件绑定
- linux kafka 搭建运行环境
- wireshark抓包图解 TCP三次握手/四次挥手详解
- Squares
- HDU 5078--Osu!【水题】
- C++内联函数
- Squares 分类: POJ 2015-08-04 11:46 3人阅读 评论(0) 收藏
- 2.0-iptables详解
- centos6.6_x64升级firefox
- Squid Epoll网络模型
- Qt 常用类(3)—— QString
- 滤镜属性
- JSON与JAVA数据的相互转换
- AngularJs 初学