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 ...
随机推荐
- Selenium3学习中遇到的问题
pytesseract识别验证码 TesseractNotFoundError: tesseract is not installed or it's not in your path brew in ...
- Java直接内存读写的例子
在Hotspot JVM上,我们能够直接对内存进行读写操作.该类的allocateMemory方法用于申请分配内存,putAddress和getAddress方法用于对直接内存进行读写. 本文将通过s ...
- 使用PS进行切图
一,设置PS 使用PS进行切图前的设置: 1,打开PS----打开PSD图片----点击窗口-----分别把:历史记录,信息,图层,三个打勾. 历史记录:可以回到之前想要的步骤,特别是不小心把图层的文 ...
- icpc 银川 H. Delivery Route SPFA优化
Problem Description Pony is the boss of a courier company. The company needs to deliver packages to ...
- decodeURI 与 decodeURIComponent 区别
1. 关于URL.encodeURI 及 encodeURIComponent: URI: Uniform Resource Identifiers,通用资源标识符 Global 对象的 encode ...
- [bzoj 4650][NOI 2016]优秀的拆分
传送门 Description 如果一个字符串可以被拆分为\(AABB\) 的形式,其中$ A$和 \(B\)是任意非空字符串,则我们称该字符串的这种拆分是优秀的. 例如,对于字符串\(aabaaba ...
- OpenJudge 1.5.36:计算多项式的值
描述 假定多项式的形式为xn+xn-1+…+x2+x+1,请计算给定单精度浮点数x和正整数n值的情况下这个多项式的值. 输入输入仅一行,包括x和n,用单个空格隔开.x在float范围内,n <= ...
- [后渗透]Linux下的几种隐藏技术【转载】
原作者:Bypass 原文链接:转自Bypass微信公众号 0x00 前言 攻击者在获取服务器权限后,会通过一些技巧来隐藏自己的踪迹和后门文件,本文介绍Linux下的几种隐藏技术. 0x01 隐藏文件 ...
- 内部类访问局部变量时,为什么需要加final关键字
是变量的作用域的问题,因为匿名内部类是出现在一个方法的内部的,如果它要访问这个方法的参数或者方法中定义的变量,则这些参数和变量必须被修饰为final.因为虽然匿名内部类在方法的内部,但实际编译的时候, ...
- select选中
比如<select class="selector"></select> 1.设置value为“全部“的项选中 复制代码代码如下: $(&quo ...