Hi forum,
I 've created an HSQLDB+JUnit test suite while trying to adapt some things I've learned while reading the book 'Java Open Source Programming - with ...'.
I am not a newbee to hibernate but slightly for HSQLDB + hibernate, maybe I am trying something stupid, but it seams too strange for me.
What I have:
-HSQLDB 1.7.1
-Hibernate 2.1
-Eclipse 3.0 M6 Plain Java Project
-A class called Product which is mapped to the table 'PRODUCTS'. It only has one id of type integer and the generator in use is 'identity'.
-A class called HibernatePersistenceManager which initalizes a hibernate session using a session factory AND uses new SchemaUpdate(config).execute(false,true) to ensure every required table is created.
-A TestCase for testing the HibernatePersistenceManager
So what's wrong?
- Well I have a test case for the manager, just for testing if it does its duty. To check how many rows a table has, I get a connection from the session and request the count of rows using select count(*) from 'tablename'.
- I have a couple of test methods named testEmpty1 to testEmpty20. Every method looks the same and checks if the number of rows of the 'PRODUCTS' table is zero. (Simply it fails if the table does not exist).
And now comes the wired thing:
- The testEmpty1 (first one) and the testEmpty5 (fith one) fails. The reason is: table PRODUCTS does not exist.
- If I am calling SchemaUpdate.execute(...) twice on init, the first and the third testEmpty* fails.
- If I am calling SchemaUpdate.execute(...) once but add a class mapping for category (looks like Product but maps on table 'CATEGORIES') also the first and the third fails.
I am very puzzled. Restarting the computer doesn't help and everytime I run the test the same result occurs. So it is reproducable but beyond my horizon.
Except those two calls everything else works like expected. I can add products, get products and all the stuff (using more complex tests to test additional behaviour) but the first and the third (or first or fiths) fails all the time.
Can someone give me a pointer or verify this? I think I've found a bug but I can not be the first one I guess :-)
Thanks,
Martin (Kersten)
|