org.dbunit.dataset.NoSuchTableException,但 table 存在

org.dbunit.dataset.NoSuchTableException, but table exists

H2 1.4.191.
数据库单元 2.5.1。
如何解决?
3个案例的代码和结果:

org.dbunit.dataset.NoSuchTableException: category
org.dbunit.dataset.NoSuchTableException: Category
org.dbunit.dataset.NoSuchTableException: CATEGORY
//
<dataset>
<Category categoryId="9223372036854775806"
      categoryName="NAME"
      categoryParentId="9223372036854775805"/>   
</dataset>
//
CREATE TABLE Category (
  categoryId       INT          AUTO_INCREMENT,
  categoryName     VARCHAR      NOT NULL,
  categoryParentId INT          NOT NULL,
  PRIMARY KEY (categoryId)
)
//Check - tried to recreate
org.h2.jdbc.JdbcSQLException: Table "CATEGORY" already exists; 

有时当您使用 dbunit 时,您需要定义您尝试使用 table 的模式,或许您可以尝试添加

<dataset>
<schema.Category categoryId="9223372036854775806"
      categoryName="NAME"
      categoryParentId="9223372036854775805"/>   
</dataset>

如果不检查您正在使用的数据源,可能是您没有指向正确的数据库或模式。

对于 dbunit,我们有一些 properties 考虑使用 Qualified table names 属性,如下所示。

DatabaseConfig dBConfig = dBConn.getConfig(); // dBConn is a IDatabaseConnection
dBConfig.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, true);