I sometimes run DbUnit tests of my Spring application's DAOs using an in-memory HSQL database, and other times using an Oracle database. It's necessary to allow Hibernate to build the schema for the HSQL database (since one doesn't already exist), but when I run the DbUnit tests against the Oracle database I do not want the schema to be modified. Currently I am commenting out the hibernate.hbm2ddl.auto property of my Hibernate SessionFactory bean when I run DbUnit tests using Oracle as my DataSource, but I expect that there's a better way to go about this. Ideally what I'd like to use is a property value for hibernate.hbm2ddl.auto which tells the schema exporter to only update/create a schema if one doesn't already exist, but I don't see such a value available for this property.
Can anyone give me suggestions on how to better approach this problem? Thanks in advance for any responses.
Yes I use update when I want the HSQL schema created, but if one already exists in the Oracle database then I don't want it modified at all, even if it's out of sync with the Hibernate mappings. What I want is a value for this Hibernate property other than update, which tells Hibernate to only create/update the schema if one doesn't exist, otherwise do nothing (i.e. do not modify an existing schema).
Maybe what I need to do is to not rely on the Hibernate automatic schema creation/update and instead somehow perform this step programmatically for my DbUnit tests only when they are using the in-memory HSQL database, which is the only time it's really needed.
subject: How to keep Hibernate from exporting a schema if one already exists?