Languages
[Edit]
EN

Spring Boot 2.x - commit and rollback transaction manually

4 points
Created by:
Erica33
439

In this short article, we would like to show how to commit and rollback transactions manually in Spring Boot in Java.

Quick solution:

  1. access transaction manager with @Autowired annotation,
  2. create transaction with getTransation() method,
  3. commit on success with commit() method,
  4. rollback on faliture with rollback() method.

Practical  example:

 

More complicated example

Edit

In this section, the presented example shows how to rollback transactions on fail in different cases.

 

See also

Edit
  1. Spring Boot 2.x - transaction with controller request 
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join