hsqldb 不支持列的 columnDefinition 属性
我已经有 hsql 数据库用于测试,并向其中添加了几个表。
我正确更新了 .dtd 和 .xml 文件,但无法运行 junit,因为 dbunit 测试用例抛出“NoSuchTableException”。
在 DAO 类中,我为罪魁祸首表添加了以下属性。
@Column(name = "keyword_id", columnDefinition = "int REFERENCES master_keyword(keyword_id)")
一旦我删除了 columnDefinition 属性,junit 就可以正常工作了。我知道 columnDefinition 是特定于数据库的,这是否意味着我们不应该在运行 junits 时使用它?
我在这上面花了很多时间。问题已解决,但对此有什么想法吗?
I already had hsql db for testing and I added a couple of tables to that.
I updated .dtd and .xml files properly but was unable to run junits as "NoSuchTableException" was being thrown from dbunit test cases.
In the DAO class I added following property for the culprit table.
@Column(name = "keyword_id", columnDefinition = "int REFERENCES master_keyword(keyword_id)")
Once I removed columnDefinition attribute, junit worked fine. I understand that columnDefinition is database specific, does that mean, we should not use this while running junits?
I spent a lot of time on this. Problem is resolved but any thoughts on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的单元测试使用注释自动创建数据库表,那么显然会考虑columnDefinition 属性:这就是它的目的。
因此,如果您在列定义中拥有特定于数据库的内容,对于您正在使用的数据库之外的另一个数据库,那么显然它不起作用。
看起来您想在这里定义一个外键约束。那么为什么不使用 OneToOne 或 ManyToOne 关联呢?
If your unit tests use the annotations to automatically create the database tables, then obviously the
columnDefinition
attribute is taken into account: that's its purpose.So if you have database-specific stuff, for another database than the one you're using, in the column definition, then obviously it won't work.
It looks like you want to define a foreign key constraint here. Why don't you use a OneToOne or ManyToOne association then?