Spirng transaction (optimistic lock) problem?

executing the following sql, in a while loop will result in the non-execution indicated in the figure. Sql uses the version field to implement optimistic locks.

clipboard.png


@Transactional(rollbackFor = Exception.class)



you can check and modify the return value by yourself. If the number of rows affected is 0, you can throw an exception by yourself. Otherwise, how many row pairs are semantically correct to perform update modifications in the database.


returns 0 because the previous statement has changed version=0+1=1, and then executed under the old conditions, of course, no data can be returned 0, but this does not mean that

has not been executed.
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-1b31d81-2b313.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-1b31d81-2b313.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?