In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the use of MYSQL nested transactions and Spring transaction propagation". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of MYSQL nested transactions and Spring transaction propagation".
Abstract
The savepoint keyword enables nested transactions. Combined with the savepoint keyword, it is easier to understand the transaction propagation of spring.
Drop table tbot create table t (an int, primary key (a)); start the transaction
Mysql transactions commit automatically by default. Turn off transaction auto-commit with the following command. (the mysql transaction feature is based on the same link, and different links have no transaction relationship, so when testing, make sure it is the same window.)
Set @ @ autocommit = 0bot select @ @ autocommit; local transaction, external transactions are committed normally-- open transaction begin;insert into t (a) values (1);-- SAVEPOINT Sten insert into t (a) values (2); RELEASE SAVEPOINT Sitcommit
Query results, 1 and 2 have been inserted successfully.
Select * from t
Local transaction rollback, external transaction commit begin;insert into t (a) values (1); SAVEPOINT s commit insert into t (a) values (2); ROLLBACK to SAVEPOINT s commit
Here, the local transaction is rolled back, the overall transaction is committed, and the query result is only 1 inserted successfully, 2 is not inserted, indicating that the external transaction has been committed and the local transaction has been rolled back.
Select * from t
Local transaction commit, external transaction rollback begin;insert into t (a) values (1); SAVEPOINT s ten insert into t (a) values (2); RELEASE SAVEPOINT s ten rollback
The global transaction is rolled back, the whole transaction is rolled back, and neither 1 nor 2 is inserted successfully.
Select * from t
Local transaction rollback, external transaction rollback
It is obvious that neither 1 nor 2 can be inserted successfully.
Thank you for your reading, the above is the content of "the usage of MYSQL nested transactions and Spring transaction propagation". After the study of this article, I believe you have a deeper understanding of the use of MYSQL nested transactions and Spring transaction propagation, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.