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