First off if this is the wrong place... sorry. I didnt think it really fit in the Hibernate area of the forum.
I am writing test cases for DAO's in a project. Rather than simulate the database access I really am going to a database.
My application will eventually be running on a MySql database, but I dont want to use that for testing. So at present when my test cases run spring calls derby which creates a new database. By using Hibernate's HBM2DDL.auto property I am creating my table structure and everything works fine happiness, right?
So my problem is (other than derby creating this annoying directory in my project for the database) derby seems very slow. At present my project is executing 81 tests of the DAO's in just over 8.5 seconds. Now I can live with 8.5 seconds delay in the build. The problem is I am only testing about 33% of the DAO. So I expect that number to probably triple. Again, 25 seconds delay during build is something I can live with. I am thinking down the road when I start testing other things like the service layer of my application (which trickles down to the DAO and DB) that number is going to go up. I really dont want to end up having a build which takes several minutes to execute!
So I have been looking at switching from derby (file based) to H2Database which according to their website (they wouldn't stretch the truth would they?) is the fastest in memory DB solution out there.
The problem I am running into is that when I execute my tests I get an error that my schema does not exist and my tests fail.
Has anyone gotten this to work? If not has anyone done something similar and can tell me what in memory DB they used and how?
The key seemed to be removing the catelog attribute of class tag in the hibernate-mapping file.
I dont really know why this broke things... But removing it fixed the problem. I dont know if its required when the application actually connects to my real database rather than this one in memory. This is part of a utility jar file and the mappings will be external to it when I actually deploy.
Anyway, my 81 tests went from like 8.5 seconds to execute down to 3.106 seconds. BIG improvement :-)