JPA - How to truncate tables between unit tests

Posted by Theo on Stack Overflow See other posts from Stack Overflow or by Theo
Published on 2010-10-13T16:19:03Z Indexed on 2010/12/21 20:53 UTC
Read the original article Hit count: 339

Filed under:
|
|
|
|

I want to cleanup the database after every test case without rolling back the transaction. I have tried DBUnit's DatabaseOperation.DELETE_ALL, but it does not work if a deletion violates a foreign key constraint. I know that I can disable foreign key checks, but that would also disable the checks for the tests (which I want to prevent).

I'm using JUnit 4, JPA 2.0 (Eclipselink), and Derby's in-memory database. Any ideas?

Thanks, Theo

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about jpa