Reputation: 15052
We use hypersonic in memory database for our DAO junit tests.
The problem is that under eclipse, each junit test drops and re-creates the table just fine, but when we build in ant, the tables stay around longer and the tests cross-contaminate.
The solutions is that, in the tear down of all of our tests, we delete all of the records from all of the tables that we use in that test. Unfortunately, our developers are not sacrosanct about maintaining these and all of a sudden the build breaks and you've got to go on search and destroy to remove the offending records.
If I could find a way to get a list of tables from hypersonic DB, then I could loop through those and remove all of the records and I could put this static method into each of the tear down methods and it would be done.
We're using hibernate, so methods that employ that would be good too.
Anyone?
Upvotes: 1
Views: 339
Reputation: 24352
If you want to drop all the tables in a schema, you can drop the schema. The default schema is called PUBLIC (which you can rename). If you drop this schema, it is recreated automatically. So to drop all tables in the public schema, use:
DROP SCHEMA PUBLIC CASCADE
Upvotes: 0
Reputation: 4745
You might want to take a look at java.sql.DatabaseMetaData.getTables.
Upvotes: 1