In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the method of separate rollback of Spring transaction for loop". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of separate rollback of Spring transaction for loop".
@ Transactional (rollbackFor = Exception.class) public void aaa (List toDoIds) {for (String toDoId: toDoIds) {try {/ / inner layer new transaction, single transaction within for loop commit or roll back sissCommonService.aaa (toDoId);} catch (Exception e) {e.printStackTrace ();}
In the second generation code, the original method aaa () is called with this, that is, transaction methods are nested. After nesting, the nested methods will not have transactions. Therefore, I built a new public Service to solve the problem of transaction nesting, added transactions to the separately proposed methods, and worked out the transaction propagation mechanism as Propagation.REQUIRES_NEW, specific code.
@ Transactional (rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) public void updateOrderInfoPersonOutOrgan (String toDoId) throws Exception {}
Propagation.REQUIRES_NEW means that if the caller currently has a transaction, it suspends the transaction and restarts the transaction. After calling this method, the method opens the transaction separately, commits each time, and rolls back the exception separately when it encounters an exception. It is good that the external method receives the thrown exception and does not handle it, so that the internal and external transactions do not affect each other.
Thank you for your reading, the above is the content of "what is the method of rolling back Spring transaction for cycle separately". After the study of this article, I believe you have a deeper understanding of what the method of separate rollback of Spring transaction for cycle is, 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.