• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring Boot JDBC Transaction Rollback not working

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I have a large project that  uses plain jdbc to store data in a H2 DB. All is working fine except transaction rollback does not work.
Because the project is very big I made a smaller project with a similar setup to reproduce the behavior.

This is the pom


The controller:


A service:

And two DAOs:



In the second DAO I deliberately throw a RuntimeException to trigger the Rollback, that does not work.

And finally this is the Configuration class:


The value of spring.datasource.h2.db.url is:



So it's not an In-Memory-DB, but a file.

Now when I run the application and call the controller the output looks like this:


So the log says in line 30 to 39 that the transaction rolls back, but when i look into the db tables the BlogPost record still gets written.
In other projects where i used JPA and Spring Data JPA the @Transaction annotation always worked fine, but in this project i can't get it running, because I don' know this kind of project setup.

I hope here someone knows where the problem is!

Thanks in advance,
Michael
reply
    Bookmark Topic Watch Topic
  • New Topic