I've setup a dbunit unittest for some DAO's I worked on. I was using HSQL (which worked) and am moving it to Oracle 11g.
The data is loaded via dbunit's FlatXmlDataSetBuilder, Spring 2.5.6 LocalContainerEntityManagerFactoryBean and Hibernate 3.4 OracleDriver.
The database is setup using synonyms and I used dbunit's DabaseConfig.setProperty() method to set the table type to "SYNONYM". It was a bit of a struggle getting that figured out. I had to debug dbunit down into IMetadataHandler.getTables() to get that working.
I'm stuck now on the getColumns() problem and not sure what to look for. Google produced GRANT SELECT on the tables, but I'm able to do SELECTs from SQL Explorer in Eclipse. I'm not knowledgeable enough about SQL to know where the SELECT on table columns should be applied (if that is really the problem).
There are several properties related to synonyms that affect the behavior of Oracle's JDBC driver.
I suggest you experiment with them.
They are detailed in the javadoc for class oracle.jdbc.OracleConnection.
The javadoc is available for download from this page.
Joined: Sep 15, 2007
Thanks for the tip Avi,
Unfortunately, oracle.jdbc.OracleConnection is not what I need. org.dbunit.ext.oracle.OracleConnection is what I am using.
Too bad that class doesn't have the synonym properties as the Oracle JDBC class.
Anyway, we've gone with an alternative approach that is working.
Could you share your approach in case others have similar issues?
I was using org.dbunit.operation.DatabaseOperation.REFRESH.execute(connection, dataSet) in my base test class that gets extended by the unit tests to load the test data from an xml file. The xml file was created from a db export of a good test data set and could be used as is this way. It worked great with HSQL.
If the database is discovered by the class to be Oracle, it doesn't use that, and instead loads the test data via connection.createStatement().execute(<sql string>). The <sql string> is read from an sql file. The xml file data set was fairly small, so converting it to a bunch of inserts cost less than continuing to fight the other problem.