不能在 DBunit 中使用 foreign table
Can not using foreign table in DBunit
我的项目使用了 SpringMVC、MyBatis 和 PostgreSql。
在 postgres 中,我有 2 个服务器:sv1、sv2。
我使用以下方法将 table 从 sv2 导入到 sv1:
import foreign schema public limit to (tbl2) from server sv2 into public;
但是,在使用DBUnit 做测试时,我无法将数据插入到外部table tbl2。例外情况是:
ERROR org.dbunit.database.DatabaseDataSet - Table 'tbl2' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap
如何在 DBUnit 中使用外部 table?
您需要配置DatabaseConfig
。
databaseConfig.setProperty(PROPERTY_TABLE_TYPE, [array of string with table types]);
要么
databaseConfig.setTableType([array with table types]);
或者配置你的 bean 并添加 属性
<property name="tableType">
<array value-type="java.lang.String">
<value>TABLE</value>
<value>FOREIGN TABLE</value>
</array>
</property>
如果您转到任何实现 DatabaseMetadata 并查找“TABLE”.[=,您可以看到 table 类型的完整映射14=]
我的项目使用了 SpringMVC、MyBatis 和 PostgreSql。
在 postgres 中,我有 2 个服务器:sv1、sv2。
我使用以下方法将 table 从 sv2 导入到 sv1:
import foreign schema public limit to (tbl2) from server sv2 into public;
但是,在使用DBUnit 做测试时,我无法将数据插入到外部table tbl2。例外情况是:
ERROR org.dbunit.database.DatabaseDataSet - Table 'tbl2' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap
如何在 DBUnit 中使用外部 table?
您需要配置DatabaseConfig
。
databaseConfig.setProperty(PROPERTY_TABLE_TYPE, [array of string with table types]);
要么
databaseConfig.setTableType([array with table types]);
或者配置你的 bean 并添加 属性
<property name="tableType">
<array value-type="java.lang.String">
<value>TABLE</value>
<value>FOREIGN TABLE</value>
</array>
</property>
如果您转到任何实现 DatabaseMetadata 并查找“TABLE”.[=,您可以看到 table 类型的完整映射14=]