使用MyBatis往MySQL数据库中插入一条记录后,需要返回该条记录的自增主键值。
刚接触mysql 跟mybatis ,不太了解,现记录如下
配置文件中如下:
<sql id="base_column">
id,userid,metadataid,downloadkey,createtime,disabletime,status,caceltime
</sql>
<!-- 插入数-->
<insert id="insertSharedownload" parameterType="shareDownLoad" useGeneratedKeys="true" keyProperty="id">
insert into sharedownload (<include refid="base_column"/>)
values (#{id},#{userid},#{metadataid},#{downloadkey},#{createtime},#{disabletime},#{status},#{caceltime})
</insert>
insert中指定了keyProperty="id",其中id代表插入的shareDownLoad对象的主键属性。
测试代码:
logger.info("增加分享记录前==========="+sdl.getId());
shareDownLoadDao.addShareDownLoad(sdl);
logger.info("增加分享记录后==========="+sdl.getId());
结果如下:
2014-10-21 13:00:49,338 INFO [********FileOperateServiceImpl] - <增加分享记录前===========null>
2014-10-21 13:00:49,391 INFO [********FileOperateServiceImpl] - <增加分享记录后===========6>
相关推荐
SpringBoot+MyBatis+Mysql+Layui实现功能完善的原创文学CMS系统 SpringBoot+MyBatis+Mysql+Layui实现功能完善的原创文学CMS系统 SpringBoot+MyBatis+Mysql+Layui实现功能完善的原创文学CMS系统 SpringBoot+...
springboot+mybatis+mysql最简单demospringboot+mybatis+mysql最简单demospringboot+mybatis+mysql最简单demospringboot+mybatis+mysql最简单demospringboot+mybatis+mysql最简单demospringboot+mybatis+mysql最简单...
这是一个java WEB小项目,用 Maven Springboot+mybatis+mysql+redis集成的小项目例子,可供新手进行参考学习,数据库是mysql 5.5 ,只是一个简单的小参考例子,测试过可以正常运行
后端: SpringBoot + MyBatis + MySQL 前端: Vue + ElementUI 教育培训机构管理系统,此系统为前后端分离方式开发的系统,技术栈为: 后端: SpringBoot + MyBatis + MySQL 前端: Vue + ElementUI 教育...
Spring mvc + mybatis+mysql 很简单的增删改查页面 适合新手学习
maven+springMVC+mybatis+velocity+mysql+junit项目框架搭建
基于Springboot+Mybatis+Mysql 实现的成绩管理系统 基于Springboot+Mybatis+Mysql 实现的成绩管理系统 基于Springboot+Mybatis+Mysql 实现的成绩管理系统 基于Springboot+Mybatis+Mysql 实现的成绩管理系统 基于...
基于SpringBoot+Mybatis+mysql的毕业生就业信息分析系统 基于SpringBoot+Mybatis+mysql的毕业生就业信息分析系统 基于SpringBoot+Mybatis+mysql的毕业生就业信息分析系统 基于SpringBoot+Mybatis+mysql的毕业生就业...
毕设项目:基于SpringBoot+MyBatis+mysql的飞机订票系统 毕设项目:基于SpringBoot+MyBatis+mysql的飞机订票系统 毕设项目:基于SpringBoot+MyBatis+mysql的飞机订票系统 毕设项目:基于SpringBoot+MyBatis+mysql的...
springboot+mybatis+mysql+layUI+thymeleaf实现对学员信息的增删改查
Springboot+MyBatis+mysql+jsp页面跳转详细示例
该项目主要技术架构包括:spring+springMVC+Mybatis+MYSQL+Redis+Maven,适合初学者,简单易懂。
springboot+mybatis+mysql+jsp+bootstrap+web.xml例子
ORM:MyBatis 数据库:MySQL 5.7 分布式缓存:Redis 本地缓存:Caffeine 消息队列:Kafka 2.13-2.7.0 搜索引擎:Elasticsearch 6.4.3 安全:Spring Security 邮件任务:Spring Mail 分布式定时任务:Spring Quartz ...
spring-boot+mybatis+mysql+maven整合,有教程,可以去我的博客看
spring+mybatis+mysql实现的用户登录功能
后端: SpringBoot + MyBatis + MySQL 前端: Vue + ElementPlus + Echarts 此系统为前后端分离方式开发的系统,技术栈为 后端: SpringBoot + MyBatis + MySQL 前端: Vue + ElementPlus + Echarts 此系统为...
基于SpringBoot+Mybatis+Mysql技术栈的前后端分离外卖管理系统.zip基于SpringBoot+Mybatis+Mysql技术栈的前后端分离外卖管理系统.zip基于SpringBoot+Mybatis+Mysql技术栈的前后端分离外卖管理系统.zip基于SpringBoot...
基于Springboot+MyBatis+MySQL实现多功能个人博客系统 项目经过严格测试,确保可以运行! 功能点: 用户注册登录功能 Markdown文章发布功能 文章分页显示 文章分类 文章标签/标签云 文章点击量 阅读排行 赞...
Maven+Spring+Spring MVC+MyBatis+MySQL,搭建SSM框架环境