dbunit java_java – org.dbunit.dataset.NoSuchColumnException

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-30 19:36   132   0

我运行测试时遇到以下错误:

org.dbunit.dataset.NoSuchColumnException: myTable.MYFIELD - (Non-uppercase input column: myfield) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.

at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)

我在org.dbunit.dataset.AbstractTableMetaData#getColumnIndex中设置了一个断点,并发现了以下内容.在IntelliJ Idea中,该方法如下所示:

public int getColumnIndex(String columnName) throws DataSetException

{

logger.debug("getColumnIndex(columnName={}) - start", columnName);

if(this._columnsToIndexes == null)

{

// lazily create the map

this._columnsToIndexes = createColumnIndexesMap(this.getColumns());

}

String columnNameUpperCase = columnName.toUpperCase();

Integer colIndex = (Integer) this._columnsToIndexes.get(columnNameUpperCase);

if(colIndex != null)

{

return colIndex.intValue();

}

else

{

throw new NoSuchColumnException(this.getTableName(), columnNameUpperCase,

" (Non-uppercase input column: "+columnName+") in ColumnNameToIndexes cache map. " +

"Note that the map's column names are NOT case sensitive.");

}

}

this.getColumns()的值不包含任何Column.columnName与参数columnName匹配的列.因此,colIndex变为null并抛出异常.

看起来DBUnit正在寻找错误的表元数据中的列索引.

我怎样才能解决这个问题?

注意:我从其他人那里继承了这段代码(没写过).

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP