I'm using HSQLDB for data layer integration testing, which is great. However, I'm finding that my foreign key constraints are getting in the way of my tests. For example, to test a simple select on one table, I have to insert dummy data into five additional tables. This makes me want to throw things.
I have JPA annotations throughout our model code, and have configured Hibernate to recreate the schema (hbm2ddl.create-drop) in configuration. The joins are being interpreted correctly as foreign key constraints when the tables are generated.
What I'd like is to either:
- Not create the foreign keys initially (ideal, cleanest), or
- Find a way to programmatically drop all the foreign keys in the database (kinda hacky but will get the job done)
If it's helpful, I'm using Spring to autowire these tests. The tests in question inherit from AbstractTransactionalJUnit4SpringContextTests.
What do you think? Can this be done?