简体   繁体   English

Hibernate Tools:外键映射到两个不同的表时的异常

[英]Hibernate Tools: Exception when Foreign Key is mapped to two different tables

I'm running the Hibernate Tools against a DB2 database that permits the same foreign key name to be used in two different tables, each related to the same PK in another table. 我正在针对DB2数据库运行Hibernate Tools,该数据库允许在两个不同的表中使用相同的外键名,每个表与另一个表中的相同PK相关。 When the tool attempts to read the schema, it throws the following exception: 当该工具尝试读取架构时,它会引发以下异常:

org.jboss.tools.hibernate.spi.HibernateException: Foreign key name (EXECUTION_FK) mapped to different tables! previous: org.hibernate.mapping.Table(PURGE_EXECUTION_TRACKING) current:org.hibernate.mapping.Table(PURGE_SCENARIO_TRACKING)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$2.execute(LazyDatabaseSchemaWorkbenchAdapter.java:138)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:108)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.readDatabaseSchema(LazyDatabaseSchemaWorkbenchAdapter.java:125)
    at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:65)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:104)

It should be possible to rename one of the FKs, but this is a large database and there appear to be many of these conflicts. 应该可以重命名其中一个FK,但这是一个大型数据库,似乎存在许多这些冲突。

Has anyone found a workaround inside Hibernate that would allow reading the schema without choking on the exception? 有没有人在Hibernate中找到一个解决方法,允许读取模式而不会阻塞异常?

I haven't found a configuration parameter to turn off this check, or any class overrides that would address this. 我没有找到一个配置参数来关闭此检查,或任何类覆盖将解决此问题。 It's also not clear if the Hibernate tools would be able to perform their reverse engineering functions if this exception could be ignored. 如果可以忽略此异常,Hibernate工具是否能够执行其逆向工程功能还不清楚。

As you can see in this topic: 正如您在本主题中看到的:

https://forum.hibernate.org/viewtopic.php?f=6&t=948998&view=next https://forum.hibernate.org/viewtopic.php?f=6&t=948998&view=next

Hibernate tools has problems to managing foreign keys in different tables with the same name. Hibernate工具在管理具有相同名称的不同表中的外键时存在问题。 I think the first option is to rename these foreign keys. 我认为第一个选项是重命名这些外键。

Sorry. 抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM