hsqldb 不支持列的 columnDefinition 属性

发布于 2025-01-06 14:16:40 字数 415 浏览 4 评论 0原文

我已经有 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 技术交流群。

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

发布评论

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

评论(1

尬尬 2025-01-13 14:16:40

如果您的单元测试使用注释自动创建数据库表,那么显然会考虑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?

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