gpt4 book ai didi

java - hibernate 映射异常 : Logical column name cannot be null

转载 作者:搜寻专家 更新时间:2023-11-01 02:21:26 25 4
gpt4 key购买 nike

关于以下 hibernate 映射异常的任何想法。下面是完整的堆栈跟踪,没有关于从哪个表发生此异常的信息。

org.hibernate.MappingException: Logical column name cannot be null
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:179)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:121)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.hibernate.MappingException: Logical column name cannot be null
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getPhysicalColumnName(InFlightMetadataCollectorImpl.java:972)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getPhysicalColumnName(InFlightMetadataCollectorImpl.java:966)
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:681)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:101)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processEndOfQueue(InFlightMetadataCollectorImpl.java:1786)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1730)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1617)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:161)
... 7 more

欢迎任何有关此异常根本原因的想法。

最佳答案

我看到了同样的错误,但我已经设法修复了它。我在 documentation 中偶然发现了这个:“许多 JPA 实现可能会在不为每个 @JoinColumn 注释指定 referencedColumnName 时抛出看似不一致的异常,这是 JPA 所要求的(即使所有引用的列名都等于引用表中的列名)。”为每个 JoinColumn 添加 referencedColumnNames 似乎为我解决了这个问题。

为了帮助缩小给我带来麻烦的类的范围,我在第 682 行的 org.hibernate.cfg.annotations.TableBinder::bindFk() 中设置了一个断点,他们调用了 referencedColumn = buildingContext.getMetadataCollector( ).getPhysicalColumnName(table, referencedColumn); 查找何时 referencedColumn 为空或 null。

关于java - hibernate 映射异常 : Logical column name cannot be null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40804594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com