Hibernate在第一次运行时正确地创建并填充了数据库。在第二次运行时,我得到了低于错误的结果。
Hibernate 5.2.0和Oracle 12c。这是个窃听器吗?当我搜索这个的时候,我几乎找不到任何信息。
@ManyToOne
@JoinColumn(name="fk_report")
@ForeignKey(name="fk_report")
private Report report;
堆栈跟踪:
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)
3条答案
按热度按时间lqfhib0f1#
看起来这是Hibernate 5.2.0中引入的错误-应该在下一个次要版本(5.2.1)中修复:https://hibernate.atlassian.net/browse/HHH-10802
yk9xbfzb2#
看起来5.2.0确实有一个错误。在5.1.0版本中,我没有任何问题。
bkhjykvo3#
我的回复可能晚了,但是对于那些将来可能会遇到它的人,您可以使用不同的模式或转到MySQL,然后选择有问题的表并转到“ALTER TABLE”,然后右键单击并删除选定的FOREIGN_KEY。我有这个过程的截图。
Image can be found here。
注意:确保您删除的外键是控制台错误中显示的外键。