How mybatis executes multiple native statements

when operating on the database, the table is locked, the field value of the table is updated, the query is returned, and finally the table is unlocked. The sql statements executed without jdbc for
are as follows:

LOCK TABLE yh WRITE;
UPDATE yh SET value = value + 1;
SELECT value FROM yh;
UNLOCK TABLES;
Mar.04,2021

1, if the program does not exist distributed, then at the program level, directly add the lock, make it a single thread, do not need to do database table lock.
2, if the program is distributed, it can be placed in the cache (redis, etc.), and then the method of accessing the cache is locked. Regularly Synchronize the cached data to the database.
3. If you have to do it in mybatis, it is recommended to call it in two parts.

a:select value from yh for update;
b:update yh set value = value + 1;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33fe8-2bef5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33fe8-2bef5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?