Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key

Tags:

hibernate

ddl

hibernate creates and fills the database correctly on the first run. On the second run, I get below error.

Hibernate 5.2.0 and Oracle 12c. Is this a bug? I find almost no information, when I google this.

    @ManyToOne
    @JoinColumn(name="fk_report")
    @ForeignKey(name="fk_report")
    private Report report;

Stacktrace:

Initial SessionFactory creation failed.org.hibernate.tool.schema.spi.SchemaManagementException: Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key named [FK_REPORT]
Exception in thread "main" java.lang.ExceptionInInitializerError
    at bo.agi.config.HibernateUtil.buildSessionFactory(HibernateUtil.java:30)
    at bo.agi.config.HibernateUtil.<clinit>(HibernateUtil.java:12)
    at bo.agi.documentation.ReportDocumenter.doReportDocumentation(ReportDocumenter.java:124)
    at bo.agi.documentation.BO_Exporter.main(BO_Exporter.java:237)
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key named [FK_REPORT]
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:727)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:708)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getForeignKeys(InformationExtractorJdbcDatabaseMetaDataImpl.java:691)
    at org.hibernate.tool.schema.extract.internal.TableInformationImpl.foreignKeys(TableInformationImpl.java:88)
    at org.hibernate.tool.schema.extract.internal.TableInformationImpl.getForeignKey(TableInformationImpl.java:99)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.findMatchingForeignKey(SchemaMigratorImpl.java:530)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.applyForeignKeys(SchemaMigratorImpl.java:506)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.performMigration(SchemaMigratorImpl.java:315)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:137)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:110)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:176)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:65)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:308)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:476)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:707)
    at bo.agi.config.H

ibernateUtil.buildSessionFactory(HibernateUtil.java:27)

like image 537
tobi Avatar asked Jun 07 '16 10:06

tobi


2 Answers

Looks like this is a bug introduced in Hibernate 5.2.0 - which should be fixed in the next minor version (5.2.1): https://hibernate.atlassian.net/browse/HHH-10802

like image 109
mkurz Avatar answered Sep 28 '22 18:09

mkurz


looks like 5.2.0 has indeed a bug. With 5.1.0 I have no issue.

like image 27
tobi Avatar answered Sep 28 '22 18:09

tobi