当前位置:网站首页>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();
}
}
边栏推荐
- The charm of SQL optimization! From 30248s to 0.001s
- Topic not received? Try this
- 【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)
- 芯片 设计资料下载
- B. Value sequence thinking
- Cnopendata American Golden Globe Award winning data
- [2022 actf] Web Topic recurrence
- Leetcode 43 String multiplication (2022.02.12)
- [CV] Wu Enda machine learning course notes | Chapter 8
- Implementation of replacement function of shell script
猜你喜欢

快速使用 Jacoco 代码覆盖率统计

自定义类加载器加载网络Class

央视太暖心了,手把手教你写HR最喜欢的简历

追风赶月莫停留,平芜尽处是春山

2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers

【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)

Codeforces Global Round 19
![[experience sharing] how to expand the cloud service icon for Visio](/img/42/dba9f78f3fb2049dad8b343b0b36e5.png)
[experience sharing] how to expand the cloud service icon for Visio

SQL优化的魅力!从 30248s 到 0.001s

Figure out the working principle of gpt3
随机推荐
PHP exports millions of data
Linux server development, detailed explanation of redis related commands and their principles
Ansible
[advanced digital IC Verification] command query method and common command interpretation of VCs tool
[VHDL parallel statement execution]
LeetCode简单题之字符串中最大的 3 位相同数字
pytest+allure+jenkins環境--填坑完畢
Introduction to basic components of wechat applet
Info | webrtc M97 update
Niu Mei's mathematical problem --- combinatorial number
Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
B. Value sequence thinking
Linux server development, MySQL index principle and optimization
Open source ecosystem | create a vibrant open source community and jointly build a new open source ecosystem!
Binary tree and heap building in C language
Linux server development, MySQL process control statement
芯片 设计资料下载
青龙面板-今日头条
2022 tea master (intermediate) examination questions and mock examination
Chip information website Yite Chuangxin