Hi all,
I working on a project that using Hibernate for DAOs (in conjunction with Spring). For our unit testing, our underlying DB2 database is being swapped for an in-memory instance of HSQLDB, by injecting a new datasource into to client code using Spring.
The problem is due to Hibernates auto creation of schemas; the hbm files look like:
Code:
<class name="xyzclass" table="xyztable">
…
Inside of the Session Factory bean, we are setting
Code:
hibernate.hbm2ddl.auto=create-drop
to dynamically create the tables (as the database is in-memory and is setup each time the JVM runs) such that the DAOs are able to use the DB without any additional configuration. However, this tries to create a table similar to the example above using SQL such as:
Code:
create table SCHEMA.TABLE (TRANSACTION_REFE…
This fails as the schema is not defined:
Code:
invalid schema name: SCHEMA in statement [create table SCHEMA.TABLE]
This has been discussed a few times, but without any resolution, esp. when using Spring. So far I can't find a solution without having my jUnit code manually create the schema (which defeats the point of using hbm2dll as the schema will only be created after this has already run), and forcing the Spring controlled beans to be lazily instantiated to control them from being loaded prior to any manual SQL being run.
Has anyone had prior experience of this, and any advice on how to overcome this problem? We're using Hibernate 3.2.1.ga.
Best regards,
-James