Reputation: 21
I'm trying to test the service which updates multiple tables from the database and I want to rollback the database to previous state after each test case. All solutions I have found are using @Transactional and @Rollback from Spring framework, but since my application is not a Spring web application, I would like to use javax @Transactional, which does not work for me.
Is this possible with javax at all or anything else except the Spring?
Upvotes: 0
Views: 1009
Reputation: 2167
Rollback a transaction isn't a good idea for test (integration test) as the constraint may not be validated before the commit.
You should:
Upvotes: 1
Reputation: 1745
Better idea is to use in-memory database: H2 https://www.h2database.com/ Recommendation for a Java in memory database
Not always and not everything in database can be rolled-back to initial state ( ex. sequences ).
Upvotes: 0