Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 815
jmarks Avatar asked Nov 09 '22 18:11

jmarks


1 Answers

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.

like image 110
leon cio Avatar answered Nov 14 '22 21:11

leon cio