classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view


Zhou, Yan
Hi there,

I am using DBUNIT 2.4.8 with Hypersonic database (in memory) and JPA 2.x (EclipseLink) to do a simple database unit test.

I am getting NoSuchTableException. Because this is in memory database, I do not have a way to see if the table is actually there.

My understanding is that, whenever entitymanager instance is created, the database tables are created in memory.  I pass in the connection from entity manager to do CLEAN_INSERT.  But it keeps giving me "NoSuchTableException" when it does DeleteAllOperation.

Here is related code and my persistence.xml.   What else could be done?

Thanks in advance,

    public void setUp() throws Exception {
        emf = Persistence.createEntityManagerFactory("mydatasource");
        em = emf.createEntityManager();   // em is an instance variable

        DatabaseOperation.CLEAN_INSERT.execute(getDatabaseConnection(), getDataSet());
    private IDatabaseConnection getDatabaseConnection() throws Exception {
        //  I am getting connection from entity manager here
        DatabaseConnection con = new DatabaseConnection(em.unwrap(java.sql.Connection.class), "public");
        con.getConfig().setFeature(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, Boolean.FALSE);
        return con;
    protected IDataSet getDataSet() throws Exception
        return new FlatXmlDataSetBuilder().build(new FileInputStream("provider.xml"));   // in my data file, there is only a few lines of Provider record.

<persistence xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="1.0">
    <persistence-unit name="HubDataSourceForTest" transaction-type="RESOURCE_LOCAL">
      <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
                <property name="eclipselink.ddl-generation.output-mode" value="database"/>
                <property name="" value="HSQL"/>
                      <property name="eclipselink.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
                      <property name="eclipselink.jdbc.url" value="jdbc:hsqldb:mem:test"/>
                      <property name="eclipselink.jdbc.user" value="SA"/>
                      <property name="eclipselink.jdbc.password" value=""/>        
        <property name="" value="WebLogic_10"/>
        <property name="eclipselink.logging.logger" value="DefaultLogger"/>


org.dbunit.dataset.NoSuchTableException: PROVIDER
        at org.dbunit.database.DatabaseDataSet.getTableMetaData(
        at org.dbunit.operation.DeleteAllOperation.execute(
        at org.dbunit.operation.CompositeOperation.execute(
        at com.medplus.certsuite.server.requestfactory.testcase.ProviderTest.setUp(
        at junit.framework.TestCase.runBare(
        at junit.framework.TestResult$1.protect(
        at junit.framework.TestResult.runProtected(
        at junit.framework.TestSuite.runTest(
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

Confidentiality Notice: The information contained in this electronic transmission is confidential and may be legally privileged. It is intended only for the addressee(s) named above. If you are not an intended recipient, be aware that any disclosure, copying, distribution or use of the information contained in this transmission is prohibited and may be unlawful. If you have received this transmission in error, please notify us by telephone (513) 229-5500 or by email ([hidden email]). After replying, please erase it from your computer system.

Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
dbunit-user mailing list
[hidden email]