Home > Back-end >  After mybatisplus with optimistic locking, automatic filling of the update time
After mybatisplus with optimistic locking, automatic filling of the update time

Time:02-19

I join in the program after the optimistic locking, automatic filling out update time of the initial null if the update time, there will be automatically populated, but when the data updated in time have original value, automatic filling is failure, is this why??????? I use mybatis - plus version 3.4.2, need not optimistic locking, can be normal use automatic filling,

For bosses to help me have a look, thank you thank you!!!!!!!!!!!!!!!!!!!!

The test program:

@ Test
Public void testOptimisticLocker () {
User User=userMapper. SelectById (4 l);
User. Elegantly-named setName (" Lily ");
User. SetEmail (" 12222222 @qq.com ");
UserMapper. UpdateById (user);
}
Optimistic locking component:

//registered optimistic locking plug-in
@ Bean
Public MybatisPlusInterceptor MybatisPlusInterceptor () {
MybatisPlusInterceptor MybatisPlusInterceptor=new MybatisPlusInterceptor ();
MybatisPlusInterceptor. AddInnerInterceptor (new OptimisticLockerInnerInterceptor ());
Return mybatisPlusInterceptor;
}
Filling strategy:

//update the filling strategy
@ Override
Public void updateFill (MetaObject MetaObject) {
The info (" start update the fill... ");
//this. StrictUpdateFill (metaObject, "updateTime", LocalDateTime. Class, LocalDateTime. Now ());
Enclosing strictUpdateFill (metaObject, "updateTime", the Date, class, new Date ());
}
  • Related