Spring Boot中mybatis insert 如何获得自增id
https://www.cnblogs.com/quan-coder/p/8728410.html
注意要显式设置主键,通过:
@Options(useGeneratedKeys = true, keyProperty = "id")
将id设置为主键返回。
https://blog.csdn.net/suwu150/article/details/52896496
一个示例(Mapper中的代码片段):
@Insert("insert into tz_lawsuits " +
"(credit_cooperative, change_date, admin, borrower, borrower_id, guarantee, litigation_principal, type, starting_end_date," +
" lawyer, action_date, litigation_costs, attorney_fees, advance, verdict_id, implementation_date, award_id, takeback_agent_fee," +
" takeback_litigation_costs, takeback_principal, outstanding_principal, responsible_person)" +
" values" +
"(#{credit_cooperative}, #{change_date}, #{admin}, #{borrower}, #{borrower_id}, #{guarantee}, #{litigation_principal}, #{type}, #{starting_end_date}," +
" #{lawyer}, #{action_date}, #{litigation_costs}, #{attorney_fees}, #{advance}, #{verdict_id}, #{implementation_date}, #{award_id}, #{takeback_agent_fee}," +
" #{takeback_litigation_costs}, #{takeback_principal}, #{outstanding_principal}, #{responsible_person})")
@Options(useGeneratedKeys = true, keyProperty = "id")
Integer insertTzLawsuitsObject(TzLawsuits tzLawsuits);
Spring Boot中mybatis insert 如何获得自增id的更多相关文章
- 【spring boot】【mybatis】spring boot中mybatis打印sql语句
spring boot中mybatis打印sql语句,怎么打印出来?[参考:https://www.cnblogs.com/sxdcgaq8080/p/9100178.html] 在applicati ...
- spring boot 中 Mybatis plus 多数据源的配置方法
最近在学习spring boot,发现在jar包依赖方面做很少的工作量就可以了,对于数据库操作,我用的比较多的是mybatis plus,在中央仓库已经有mybatis-plus的插件了,对于单数据源 ...
- Spring Boot中MyBatis的使用
orm框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,一个是宣称可以不用写一句SQL的hibernate,一个是可以灵活调试动态sql的mybatis,两者各有特点,在企业级系统开 ...
- Mybatis insert时返回自增id
SelectKey在Mybatis中是为了解决Insert数据时不支持主键自动生成的问题,他可以很随意的设置生成主键的方式. 详细看这里:http://www.cnblogs.com/SimonHu1 ...
- Spring boot jpa 设定MySQL数据库的自增ID主键值
内容简介 本文主要介绍在使用jpa向数据库添加数据时,如果表中主键为自增ID,对应实体类的设定方法. 实现步骤 只需要在自增主键上添加@GeneratedValue注解就可以实现自增,如下图: 关键代 ...
- Spring Boot中使用MyBatis注解配置详解(1)
之前在Spring Boot中整合MyBatis时,采用了注解的配置方式,相信很多人还是比较喜欢这种优雅的方式的,也收到不少读者朋友的反馈和问题,主要集中于针对各种场景下注解如何使用,下面就对几种常见 ...
- Spring Boot 中使用 MyBatis 整合 Druid 多数据源
2017 年 10 月 20 日 Spring Boot 中使用 MyBatis 整合 Druid 多数据源 本文将讲述 spring boot + mybatis + druid 多数据源配置方 ...
- spring boot中连接数据库报错500(mybatis)
spring boot中连接数据库报错500(mybatis) pom.xml中的依赖 <!-- 集成mybatis--> <dependency> <groupId&g ...
- Spring Boot 整合 Mybatis 实现 Druid 多数据源详解
摘要: 原创出处:www.bysocket.com 泥瓦匠BYSocket 希望转载,保留摘要,谢谢! “清醒时做事,糊涂时跑步,大怒时睡觉,独处时思考” 本文提纲一.多数据源的应用场景二.运行 sp ...
随机推荐
- PHP搭建大文件切割分块上传功能示例
转载:https://www.jb51.net/article/101931.htm 背景 在网站开发中,文件上传是很常见的一个功能.相信很多人都会遇到这种情况,想传一个文件上去,然后网页提示“该文件 ...
- electron中引入jquery
<!-- Insert this line above script imports --> <script>if (typeof module === 'object') { ...
- 远程jupyter+pycharm配置
前言 作为一个数据工程师,最喜欢的事情就是不停的在现实的服务端环境调试代码的参数.我们在本地的环境与生产的状况决然不同,我们一开始在本地写代码测试再部署到服务端的三板斧就不适用了. 最好的方式可以直接 ...
- 建立component的多种方法
vue之component 在Vue.js中定义组件模板的七种方式 终于搞懂了vue 的 render 函数(一) Vuejs2.0学习(Render函数,createElement,vm.$slot ...
- IE下iframe不能正常加载,显示空白
下午帮忙看了一个web问题,index.html中嵌入<iframe>来加载同文件目录下的一个页面,在多个浏览器下测试,发现IE浏览器中会出现问题,<iframe>不能正常加载 ...
- 为什么深度(Ubuntu)Linux挂载NTFS分区只读不可写?
如前所述,经扩展,Dell Vostro 1520笔记本电脑拥有了两块硬盘. 本着旧物利用的心思,在其中一块256GiB固态盘上安装了深度linux,同时挂载另一块2TiB机械盘作为存储盘. 这块 ...
- 【转】使用 Ansible 实现数据中心自动化管理
长久以来,IT 运维在企业内部一直是个耗人耗力的事情.随着虚拟化的大量应用.私有云.容器的不断普及,数据中心内部的压力愈发增加.传统的自动化工具,往往是面向于数据中心特定的一类对象,例如操作系统.虚拟 ...
- int(“1.6”),int(1.6)输出结果?
>>> int("1.6") Traceback (most recent call last): File , in <module> ValueE ...
- [vsftpd] ubuntu14.04 ansible剧本安装vsftpd流程及报错排查
需求: 在ubuntu14.04机器上搭建ftp服务,ftp账号通过winscp软件登录后,仅可增删改/data/wwwroot目录. 一.安装步骤 1.apt 安装vsftpd apt-get in ...
- 内存分析工具 MAT 的使用【转】
转自:http://blog.csdn.net/aaa2832/article/details/19419679/ 1 内存泄漏的排查方法 Dalvik Debug Monitor Server (D ...