Mybatis updates the field, and the reason why the datetime field is not updated is automatically updated to the current system time

describe

When using mybatis to update data today, it was found that the value of the time field has been automatically updated to the value of the current timestamp.
Use debug to print and execute sql to find that the statement that does not modify the datetime field.

reason

Finally, it was found that the reason was the structure of the table, and the field of the datetime type was checked to update according to the current timestamp
insert image description here

Solution

1. Use the Navicat tool to solve

Remove the update of the datetime type field according to the current timestamp
insert image description here

2. You can also use sql statement to modify

alter table tableName change filedName fieldName timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;

Assuming that the field (time) of the table name (tab_user) needs to be removed and updated according to the current timestamp , just write it like this

alter table tab_user change time time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;

おすすめ

転載: blog.csdn.net/qq_40542534/article/details/114791445