当前位置:网站首页>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();
}
}
边栏推荐
- Bugku CTF daily one question chessboard with only black chess
- A bit of knowledge - about Apple Certified MFI
- Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
- [UVM foundation] what is transaction
- mysql多列索引(组合索引)特点和使用场景
- Ansible
- dash plotly
- LeetCode 90:子集 II
- Use and analysis of dot function in numpy
- Linux server development, MySQL index principle and optimization
猜你喜欢
Linux server development, MySQL index principle and optimization
JSON data flattening pd json_ normalize
Linux server development, MySQL transaction principle analysis
The charm of SQL optimization! From 30248s to 0.001s
2022茶艺师(初级)考试题模拟考试题库及在线模拟考试
Why should we understand the trend of spot gold?
LeetCode简单题之字符串中最大的 3 位相同数字
Force buckle 145 Binary Tree Postorder Traversal
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
探索干货篇!Apifox 建设思路
随机推荐
Binary tree and heap building in C language
[CV] Wu Enda machine learning course notes | Chapter 8
Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
Introduction to basic components of wechat applet
太真实了,原来自己一直没有富裕起来是有原因的
[VHDL parallel statement execution]
Téléchargement des données de conception des puces
Rust Versus Go(哪种是我的首选语言?)
Custom class loader loads network class
C语言通信行程卡后台系统
What is the interval in gatk4??
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
game攻防世界逆向
Explore dry goods! Apifox construction ideas
C language flight booking system
青龙面板--花花阅读
OpenJudge NOI 2.1 1752:鸡兔同笼
Value sequence (subsequence contribution problem)
Linux server development, MySQL stored procedures, functions and triggers
Common validation comments