HIbernate架构更新错误

发布于 2024-08-02 17:31:05 字数 933 浏览 4 评论 0原文

在 Jboss 服务器启动期间,我得到以下堆栈跟踪。我想知道为什么 JPA 试图改变看起来很好的表以及如何传递这些错误消息。 谢谢

2009-08-03 11:28:49,683 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] 不成功:更改表 BDPARAMS 添加约束 FK61733C48FA34BFDC 外键 (ITEMID) 引用 RTELMENT 2009-08-03 11:28:49,683 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] 不成功:更改表 BDPARAMS 添加约束 FK61733C48FA34BFDC 外键 (ITEMID) 引用 RTELMENT 2009-08-03 11:28:49,683 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: 表中已存在这样的引用约束

2009-08-03 11:28:49,683 错误 [org.hibernate .tool.hbm2ddl.SchemaUpdate] ORA-02275:表中已存在这样的引用约束

2009-08-03 11:28:49,745 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] 不成功:更改表 CONTENTITEM 添加约束 FK692B5EEC44F32395外键 (parent_id) 引用 CONTENTLOCATION 2009-08-03 11:28:49,745 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] 不成功:更改表 CONTENTITEM 添加约束 FK692B5EEC44F32395 外键(parent_id)引用 CONTENTLOCATION 2009-08-03 11:28:49,745 错误 [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275:表中已存在这样的引用约束

During the startup of Jboss server, I get the following stacktrace. I wonder why JPA is trying to alter tables that seem to be fine and how to get passed these ERROR messages.
Thanks

2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table BDPARAMS add constraint FK61733C48FA34BFDC foreign key (ITEMID) references RTELEMENT
2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table BDPARAMS add constraint FK61733C48FA34BFDC foreign key (ITEMID) references RTELEMENT
2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table CONTENTITEM add constraint FK692B5EEC44F32395 foreign key (parent_id) references CONTENTLOCATION
2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table CONTENTITEM add constraint FK692B5EEC44F32395 foreign key (parent_id) references CONTENTLOCATION
2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

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

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

发布评论

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

评论(4

以往的大感动 2024-08-09 17:31:05

就我而言,当我将 default_schema name 添加到 Hibernate 配置文件时,问题就解决了:

<property name="hibernate.default_schema" value="db_default_schema_name" />

具体来说,在 Play Framework 2.4 中,我将以上行添加到 conf\META-INF\persistence.xml 文件。

使用的休眠版本:4.3.11

In my case, the problem solved when I added the default_schema name to Hibernate configuration file:

<property name="hibernate.default_schema" value="db_default_schema_name" />

Specifically, in Play framework 2.4, I added the above line to conf\META-INF\persistence.xml file.

Hibernate version used: 4.3.11

蓝天白云 2024-08-09 17:31:05

就我而言,在更改项目中的 java 包结构后出现错误消息。我认为 hibernate 对此有点困惑。

我有类似的错误(更改表...添加约束)并且我正在使用 Oracle DB 10g。
对我来说,最简单的解决方案是导出相关表(插入)的数据,删除它们,启动再次创建表的应用程序,然后再次导入表数据。然后 Hibernate 再次自行创建表,错误消息就消失了!

In my case the error messages occoured after I changed the java package structure in my project. I think hibernate was a bit confused about that.

I had similar errors (alter table ... add constraint) and I am using Oracle DB 10g.
For me the easiest solution was to export the data of the concerned tables (inserts), delete them, start the application which creates the tables again, and then import the table data again. Then Hibernate creates the tables again by itself and the error messages are gone!

墨小沫ゞ 2024-08-09 17:31:05

我遇到了同样的错误,但通过几个简单的步骤修复了它。

转储当前数据库 Mysqldump out current.sql
更改 hibernate.cfg 来创建,以便重新创建数据库表
转储新数据库 mysqldump out new.sql

将create table new复制到current
在 current.sql 中重新插入数据库 mysql

I had the same error but fixed it with a few simple steps.

Dump the current database Mysqldump out current.sql
Change hibernate.cfg to create so it recreates the database table
Dump the new database Mysqldump out new.sql

Copy the create table new to current
reinsert database mysql in current.sql

独享拥抱 2024-08-09 17:31:05

我也遇到过类似的错误,问题源于 jdbc 子系统获取元数据的不准确。元数据返回告诉 hibernate 约束不存在,但实际上它不存在 - 可能有多种原因。我建议尝试不同的数据库管理系统,也许问题是由于当前用户和生成表的用户之间的用户差异造成的。您的映射也可能有问题。

但最终解决此问题的唯一万无一失的方法是在启动时关闭架构同步。

I've had similar errors and the problems stem from inaccuracies in the meta data fetch by the jdbc sub-system. The meta data comes back to tell hibernate the constraint is not there but in reality it is not - could be for a number of reasons. I would suggest trying a different dbms also maybe the issue is due user differences between current and user that generated the table. There could also be something wrong with your mapping.

But ultimately the only fool proof way to fix it is to turn off schema sync on startup.

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