Search code examples
grailsgroovygrails-ormdbunitgrails-2.0

Grails 2 - Domain model inheritance causing NO_SUCH_TABLE in DbUnit?


In Grails 1.3.7, I have a domain model like this:

abstract class A {
   Long id
   String a

   static constraints = {
      a(nullable:true)
   }
}

class B extends A {
   static mapping = {
      table "my_table"
      version false
      columns {
         id column: 'oid'
      }
   }
}

In 1.3.7, my tests pass fine. In upgrading to Grails 2.0.0, however, I'm hitting the following:

|  org.dbunit.dataset.NoSuchTableException: MY_TABLE
    at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:288)
    at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
    at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
    at org.dbunit.operation.TransactionOperation.execute(TransactionOperation.java:78)

If I undo the inheritance hierarchy and rely on copy+paste, these errors are "fixed." What could be going on to cause this failure?


Solution

  • Just don't use dbunit. It's an awful testing strategy anyway.