Integration tests on JPA repositories
Configuration
First add the corresponding dependencies in the pom.xml
:
Create the integration test with the right annotations:
By default, the transactions in the tests are rollbacked.
When testing the JPA methods, I got the following message “Rolled back transaction for test”.
I think it’s because it’s a test, so it will always rollback as to have isolated tests, so it’s not an issue.
If you want to disable auto rollback, just add the annotation @Rollback(false)
, e.g. on class level:
Or on method level:
Resources