DB单元;表/列名称区分大小写的混淆

发布于 2024-08-20 14:38:49 字数 2168 浏览 3 评论 0原文

当我启动应用程序时,我收到此错误,

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

我不太确定为什么会收到此错误,因为我的表/列名称全部以大写形式引用(即使消息坚持认为这不应该是问题) )

我的表:

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> 

我的域实体的片段:

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

测试日期的片段我试图强制使用 DBUnit:

<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>

我想不出其他可以尝试的东西,已经删除了表并重新编译了 java 代码,有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

浪荡不羁 2024-08-27 14:38:49

您是否尝试将已设置的 ID 放入数据库客户端? ID 列是只读的,只有数据库可以“写入”它。

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

怪我入戏太深 2024-08-27 14:38:49

在向我的一个实体添加一列(使用内存 HSQL 数据库)后,我也遇到了这个问题。

我通过简单地删除之前生成的临时文件来解决这个问题:mem:testdb.log、mem:testdb.properties 和 mem:testdb.script

为什么会出现这个错误? =>数据库模式存储在 mem:testdb.script 文件中,并且在修改实体时不会重新生成。

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.

去了角落 2024-08-27 14:38:49

我已通过将提到的列添加到我的实体来修复该错误。

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

携君以终年 2024-08-27 14:38:49

我遇到了同样的错误,幸运的是我们之前编写了一些其他测试,发现在大多数教程中,编写 xml 的格式是针对 FlatXMLDataSet 如果您使用的是 XML 数据集,那么正确的版本如下所示底部的链接了解更多信息。

它应该采用以下格式。

<?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>

欲了解更多信息,请访问此链接。

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

我再一次在另一个项目中遇到这个错误,我们有一个模型类的层次结构,一些hibernate如何用来创建一个有7列的表角色,但在使用DBUnit运行它时,它无法创建列(只创建了5个),因此它抛出这个错误,解决方案:手动创建这个表和另外3个不是由hibernate创建的关系表。

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.

杀お生予夺 2024-08-27 14:38:49

如果你设置 format = flat,这个错误就会随着 mysql 和 hsql 消失

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文