toplink.target.databaseproperty missing from the persistence.xml file. This was outlined in a useful blog TopLink JPA and HSQLDB Quirk.
Even after making these changes however, I still could not get toplink to properly create the tables. It turns out, I had several entity beans which had name fields defined as
unique=true. This caused the
UNIQUEkeyword to be written in the
CREATE TABLEstatements by Toplink which appears to be an invalid syntax for the HSQLDB database. After removing this JPA constraint from the affected objects I was able to successfully create the tables and run my tests. I also had some minor refactoring to do in some SQL utilities to leverage the persistenceUnit configuration, but I was very impressed with the speed.
Overall, my test suite went from executing in approximately eighteen seconds down to just four. While eighteen seconds may not seem like a long time, it was sufficiently long to disrupt my work efficiency. I decided to retain my MySQL peristence unit (for occasional "live" DB testing), and have now configured two test targets in Eclipse which take a
org.javad.jpa.serviceNameenvironment variable to switch between the
The final activity I will have left to do, is to determine a way to reinsert the unique statements in my entity beans without have the SQL generated for HSQLDB. There are a few threads out there, so I should be able to come up with something.
Finally, here is my persistence unit configuration for the HSQLDB database:
<persistence-unit name="hsqldb" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.PersistenceProvider</provider> <class>org.javad.stamp.model.Album</class> <class>org.javad.stamp.model.CatalogueNumberReference</class> <class>org.javad.stamp.model.Category</class> <class>org.javad.stamp.model.Country</class> <class>org.javad.stamp.model.Stamp</class> <class>org.javad.stamp.model.StampCollection</class> <class>org.javad.model.ClassVersion</class> <class>org.javad.services.TestEntityWithIdentity</class> <properties> <property name="toplink.jdbc.user" value="sa"/> <property name="toplink.jdbc.password" value=""/> <!-- <property name="toplink.logging.level" value="FINEST"/> --> <property name="toplink.jdbc.url" value="jdbc:hsqldb:mem:."/> <property name="toplink.jdbc.driver" value="org.hsqldb.jdbcDriver"/> <property name="toplink.ddl-generation" value="create-tables"/> <property name="toplink.target-database" value="HSQL"/> </properties> </persistence-unit>