当前位置:网站首页>Myabtis_Plus
Myabtis_Plus
2022-07-07 04:55:00 【呆小呆啊】
一.自动填充
- 准备工作 添加新的字段create_time,update_time。
- 在实体类中需要进行自动填充的字段添加注解
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@TableFileld(fill = FileldFill.INSERT_UPDATE)
private Date uodateTime;
乐观锁
什么是乐观锁:
是用于解决问题的方案:
丢失更新问题。张三,李四同时改工资。张三将工资改为9000,正常的情况应该是李四将9000的工资改为100,而不是将5000改为100。
添加version版本号。更新之后版本号做出改变。另外一个人版本号不一致就不能提交了。
在表中添加字段version
在实体类属性上添加@Version注解
@Version
private Integer version;
- 注册乐观锁插件
在MybatisPlusConfig中注册Bean
@Configuration
@MapperScan("com.janson.mybatis_plus.mapper")
public class MybatisPlusConfig {
/** *乐观锁插件 **/
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
return new OptimisticLockerInterceptor();
}
}
边栏推荐
- dash plotly
- Figure out the working principle of gpt3
- Zsh shell adds automatic completion and syntax highlighting
- 2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
- Niu Mei's mathematical problem --- combinatorial number
- 【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
- Common validation comments
- Leetcode 90: subset II
- 央视太暖心了,手把手教你写HR最喜欢的简历
- Linux server development, MySQL stored procedures, functions and triggers
猜你喜欢
Explore Cassandra's decentralized distributed architecture
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
Shell 脚本的替换功能实现
追风赶月莫停留,平芜尽处是春山
Record a stroke skin bone error of the skirt
Numbers that appear only once
Use and analysis of dot function in numpy
Problem solving: unable to connect to redis
A bit of knowledge - about Apple Certified MFI
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
随机推荐
【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
青龙面板--花花阅读
Visualization Document Feb 12 16:42
Topic not received? Try this
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
Force buckle 145 Binary Tree Postorder Traversal
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
pytest+allure+jenkins環境--填坑完畢
You Li takes you to talk about C language 6 (common keywords)
Chip design data download
Few-Shot Learning && Meta Learning:小样本学习原理和Siamese网络结构(一)
微信小程序基本组件使用介绍
[UVM practice] Chapter 2: a simple UVM verification platform (2) only driver verification platform
开源生态|打造活力开源社区,共建开源新生态!
Avatary的LiveDriver试用体验
LeetCode简单题之判断一个数的数字计数是否等于数位的值
Summary of redis functions
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
Content of string