DBunit; confusion over case sensitivity on table/column names
Asked Answered
R

5

4

I'm getting this error when I start up my application

Caused by: org.dbunit.dataset.NoSuchColumnException: CLIENT.ID -  (Non-uppercase input column: ID) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive

I'm not too sure why I'm getting this, since my table/column names all all referenced in upper case(even though the message insists this shouldn't be an issue)

My table :

mysql> describe CLIENT;
+------------------+--------------+------+-----+---------+----------------+
| Field            | Type         | Null | Key | Default | Extra          |
+------------------+--------------+------+-----+---------+----------------+
| ID               | int(11)      | NO   | PRI | NULL    | auto_increment |
| jdoDetachedState | tinyblob     | YES  |     | NULL    |                |
| NAME             | varchar(255) | NO   |     | NULL    |                |
| ADDRESS1         | varchar(255) | YES  |     | NULL    |                |
| ADDRESS2         | varchar(255) | YES  |     | NULL    |                |
| COUNTRY          | varchar(255) | YES  |     | NULL    |                |
| COUNTY           | varchar(255) | YES  |     | NULL    |                |
| MAINPHONENUMBER  | varchar(255) | YES  |     | NULL    |                |
| POSTCODE         | varchar(255) | YES  |     | NULL    |                |
| SECTOR           | varchar(255) | YES  |     | NULL    |                |
| TOWN             | varchar(255) | YES  |     | NULL    |                |
| WEBSITEURL       | varchar(255) | YES  |     | NULL    |                |
+------------------+--------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)

mysql> 

Snippet of my domain entity :

@Id
@GeneratedValue
@Column(name="ID")
private Integer id;

Snippet of test date I'm trying to force DBUnit to use:

<dataset>
  <CLIENT ID="-1"
    ADDRESS1="Endeavour House"
    ADDRESS2="Russell Rd"
    COUNTRY="England"
    COUNTY="Suffolk"
    MAINPHONENUMBER="0845 606 6067"
    NAME="Suffolk County Council"
    POSTCODE="IP1 2BX"
    SECTOR="Local Government"
    TOWN="Ipswich"
    WEBSITEURL="www.suffolk.gov.uk"/>
</dataset>

I can't think of anything else to try, have dropped tables and recompiled java code, any ideas?

Resultant answered 5/2, 2010 at 21:8 Comment(4)
It looks like there might be an open bug about this. jira.unitils.org/browse/UNI-134 Does that look like what is happening to you?Kahaleel
Please show a bigger part of your dataset.Esoterica
Hmm, weird. You should maybe add the version of dbunit you are using but this looks like a bug. I'd post this to the dbunit-user mailing list and maybe open an issue (sourceforge.net/tracker/?group_id=47439&atid=449491)Esoterica
I was using 2.4.2, but 2.4.7 gives same outcomeResultant
Y
2

Aren't you trying to put to database Client with ID already set? ID column is read-only, only database can "write" to it.

Yalonda answered 5/2, 2010 at 21:34 Comment(1)
Possibly, but if I remove the "ID" part from my testData.xml, I get the same error for the next field down, being "address1". Is it possible all fields are read only?Resultant
C
2

I've also had this problem after adding a column to one of my entities (using an in-memory HSQL database).

I managed to solve this problem by simply deleting the temporary files that had previously been generated: mem:testdb.log, mem:testdb.properties and mem:testdb.script

Why did this error occur? => A database schema is stored in the mem:testdb.script file and is not re-generated when the entity is modified.

Centipoise answered 6/1, 2012 at 11:55 Comment(0)
A
2

I have fixed the error by adding the mentioned column to my entity.

Amain answered 2/12, 2015 at 9:9 Comment(1)
This fixed it for me as well.Catastrophe
V
1

I ran into the same error, fortunately we had some other test written earlier and found that in most of the tutorials the format the way the xml is written is for the FlatXMLDataSet if you are using XML data set then the correct version is as follow checkout the link at the bottom for more information.

it should be in following format.

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
    <table>
        <column>id</column>
        <column>name</column>
        <column>department</column>
        <column>startDate</column>
        <column>endDate</column>
        <row>
            <value>999</value>
            <value>TEMP</value>
            <value>TEMP DEPT</value>
            <value>2113-10-13</value>
            <value>2123-10-13</value>
        </row>
    </table>
</dataset>

For more information go to this link.

http://dbunit.sourceforge.net/components.html#FlatXmlDataSet

One more time I faced this error in another project, we have a hierarchy of model class, some how hibernate used to create a table Role with 7 columns but while running it with DBUnit it was unable to create the columns(Only 5 were created) hence it was throwing this error, Solution : Manually created this table and 3 more relationship tables which were not created by hibernate.

Vimineous answered 21/11, 2013 at 9:44 Comment(0)
G
0

this error goes away with mysql and hsql if you make format = flat

Gastro answered 8/9, 2010 at 21:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.