Hibernate Tools: Exception when Foreign Key is mapped to two different tables
Asked Answered
R

1

6

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. 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.

Has anyone found a workaround inside Hibernate that would allow reading the schema without choking on the exception?

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.

Rooted answered 19/2, 2015 at 19:15 Comment(0)
B
2

As you can see in this topic:

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. I think the first option is to rename these foreign keys.

Sorry.

Bethsaida answered 24/7, 2019 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.