当前位置:网站首页>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();
}
}
边栏推荐
- Paddlepaddle 29 dynamically modify the network structure without model definition code (relu changes to prelu, conv2d changes to conv3d, 2D semantic segmentation model changes to 3D semantic segmentat
- Leetcode 90: subset II
- Shell 脚本的替换功能实现
- 2022 tea master (intermediate) examination questions and mock examination
- [UVM practice] Chapter 1: configuring the UVM environment (taking VCs as an example), run through the examples in the book
- Pytorch(六) —— 模型调优tricks
- Hands on deep learning (IV) -- convolutional neural network CNN
- 青龙面板--花花阅读
- 【VHDL 并行语句执行】
- 探索干货篇!Apifox 建设思路
猜你喜欢

Niu Mei's mathematical problem --- combinatorial number

2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions

【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
![[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

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

LeetCode中等题之我的日程安排表 I

【数字IC验证快速入门】11、Verilog TestBench(VTB)入门

有 Docker 谁还在自己本地安装 Mysql ?

PHP exports millions of data

2022茶艺师(初级)考试题模拟考试题库及在线模拟考试
随机推荐
Explore dry goods! Apifox construction ideas
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
The principle and implementation of buffer playback of large video files
LeetCode 90:子集 II
Summary of redis functions
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
Figure out the working principle of gpt3
LeetCode简单题之判断一个数的数字计数是否等于数位的值
QT learning 28 toolbar in the main window
3D reconstruction - stereo correction
2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
Codeforces Global Round 19
Linux server development, SQL statements, indexes, views, stored procedures, triggers
让Livelink初始Pose与动捕演员一致
Introduction to basic components of wechat applet
贝叶斯定律
快速使用 Jacoco 代码覆盖率统计
青龙面板--整理能用脚本
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers