DBunit 和数据集列
我想尝试使用 DBUnit 进行单元测试,但我的数据集有问题。
这是我的持久性对象:
@Entity
@Table(name = "personnes")
public class Personne implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer pk;
@Column
private String name;
}
和我的数据集:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<personnes name="toto" pk="1" />
</dataset>
我的问题是名称列,我收到此错误:
org.dbunit.dataset.NoSuchColumnException: personnes.NAME - (Non-uppercase input column: name) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.
我不明白为什么 dbunit 搜索列“NAME”,而我的列是“name”。
感谢您的帮助。
I want to try to make unit test with DBUnit but I have a problem with my dataset.
Here is my persistence object:
@Entity
@Table(name = "personnes")
public class Personne implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer pk;
@Column
private String name;
}
And my dataset:
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<personnes name="toto" pk="1" />
</dataset>
My problem is with the name column, I get this error:
org.dbunit.dataset.NoSuchColumnException: personnes.NAME - (Non-uppercase input column: name) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.
I don't understand why dbunit search a column "NAME" whereas my column is "name".
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚通过将 dbunit 从版本 2.4.8 恢复到 2.2.2 解决了这个问题。我将它与unitils 3.8 一起使用。
I just solved this issue by reverting dbunit from version 2.4.8 to 2.2.2. I'm using it with unitils 3.8.
您的 JPA 供应商适配器可能仅以大写形式创建列名称。您可以使用列注释隐式定义列名称。
It is possible that your JPA vendor adapter is creating column names in UPPER CASE only. You could define column names implicitly with Column annotation.