Spring Boot中mybatis insert 如何获得自增id
2024-09-01 13:58:23
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);
最新文章
- PHP批量删除做法
- jquery validate ajax submit form
- Visual Studio Online Integrations-Planning
- 9.0 alpha 版安装出现 could not execute command lessc 的问题
- VVDocumenter-Xcode 规范注释生成器 插件之安装调试适应新版本
- 干货:yii日志功能详解
- Android studio libs目录
- Quick Tip: How to Add Syntax Highlighting to Any Project
- 属性(Attribute)资源
- (转)Spring事务配置的五种方式
- python基于万象优图识别图片中的中文
- Your project path contains non-ASCII characters
- MySQL复制表-CREATE SELECT
- HTML(一)
- 018-Go将磁盘目录实现简单的静态Web服务
- android--------自定义控件 之 属性篇
- ClientDataset 三层 var and out arguments must match parameter
- 解决linux-mysql 登录时,报异常:Access denied for user 'root'@'localhost'
- MindMaster安装教程以及激活破解教程
- python 替换指定目录下,所有文本字符串