How to solve the problem that Transactional comments are not rolled back
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.