Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that Transactional comments are not rolled back

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to solve the problem of non-rollback of Transactional comments, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Resolve that Transactional comments are not rolled back

1. Check to see if your method is public.

two。 Whether your exception type is unchecked exception. Null pointer exception is unchecked exception

What if I want to roll back the check exception? just write down the exception type on the note.

@ Transactional (rollbackFor= {Exception.class.RuntimeException.class})

Similarly, there are norollbackFor, custom exceptions that are not rolled back.

In addition, if the try catch operation has been performed in service, the transaction will not be rolled back because it has been caught.

3. The database engine supports transactions. If it is mysql, note that the table uses an engine that supports transactions, such as innodb. If it is myisam, transactions do not work.

4. Whether the parsing of annotations is enabled

5. Whether spring scanned your package, the following is the package scanned under org.test.

The above content is how to solve the problem that Transactional annotations can't be rolled back. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report