问题是现有的Oracle表(我无法更改)具有混合大小写列名,例如
create table BADTAB ( ID varchar(16) not null, "Name" varchar2(64),
constraint I_BADTAB_PK PRIMARY KEY(ID) );
当我尝试从XML数据集执行DBUnit INSERT时,它失败了
Caused by: java.sql.SQLException: ORA-00904: "NAME": invalid identifier
当我将列名括在引号中时,它将失败
<column>"Name"</column>
org.dbunit.dataset.NoSuchColumnException: BADTAB."NAME" - (Non-uppercase input column: "ReadingsPres") in ColumnNameToIndexes cache map.
Note that the map's column names are NOT case sensitive.
at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)
...
问题: 如何覆盖DBUnit的列元数据以使其识别小写列名? 我将覆盖哪些类以及如何将它们注入到DBUnit测试运行中?
答案 0 :(得分:0)
此前有一些关于此org.dbunit.dataset.NoSuchTableException: Did not find table 'xxx' in schema 'null'
的讨论您应该能够设置数据库配置属性以满足区分大小写的名称:
DatabaseConfig config = databaseConnection.getConfig();
config.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, true);