Notes on Spring Transactions

1. When using spring transactions, if there are asynchronous tasks such as mq push, etc. in the business, these asynchronous tasks cannot be placed in the transaction, and dirty reads may occur.

2. When using Junit for unit testing involving transactions, you need to add the @Rollback(false) annotation, true means the data is cleared after the transaction is committed, and false means the data is retained

3. When using mybatis and mysql, if the database is InnoDB, a transaction must be added when inserting or modifying data. The transaction is not only for rollback, but also a guarantee of whether it needs to be committed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325926743&siteId=291194637