开发者

DbUnit doesnt see Oracle column NoSuchColumnException

DbUnit settings:

DatabaseConfig config = connection.getConfig();
config.setProperty(DatabaseConfig.FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES, true);
config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new org.dbunit.ext.oracle.OracleDataTypeFactory());

Code:

@Test
    @DataSet(value="ReportTest.testPropagationToChild.xml", loadStrategy=RefreshLoadStrategy.class)
    public void testPropagationToChild() {

Dataset:

<dataset>
    <REPORT ID="-1" NODE_NAME="TG1" NODE_LEVEL="2" PARENT_ID="0" RENA_STATUS="1" PSR_STATUS="1" PSR_AMOUNT="200" RENA_AMOUNT="1000" PSR_LAST_UPDATED_BY="u11" RENA_LAST_UPDATED_BY="u2"/>

Table:

 ID     PARENT_ID   NODE_NAME     NODE_LEVEL     RENA_STATUS     RENA_LAST_UPDATED     RENA_LAST_UPDATED_BY     RENA_AMOUNT           PSR_STATUS     PSR_LAST_UPDATED     PSR_LAST_UPDATED_BY     PSR_AMOUNT     RENA_COMMENT     ADDITIONAL_COMMENT

Exception:

Caused by: org.dbunit.data开发者_如何学编程set.NoSuchColumnException: REPORT.PSR_LAST_UPDATED_BY -  (Non-uppercase input column: PSR_LAST_UPDATED_BY) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive. 

Other columns (like ID etc) are OK for import. I'm using Oracle 11g, dbunit 2.4.8

Why it fails to import PSR_LAST_UPDATED_BY? Thanks!


I believe your exception is telling you what's wrong:

(Non-uppercase input column: PSR_LAST_UPDATED_BY) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.

It appears to me that your column was created with mixed case, in which case it needs to be referred to in double-quotes, in exactly the case that's in the dictionary. Not sure how you do that in DBUnit. Apparently there's a "map" somewhere that defines the table's columns, and assumes upper case column names. Preferrably, the column should be renamed to all upper case.

This SO question/answer illustrates what I believe is going on here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜