Hibernate 4到5迁移-无法在@MapKey上构建Hibernate SessionFactory

时间:2018-07-23 15:22:51

标签: hibernate jpa-2.1 hibernate-5.x jboss-eap-7

我有3个实体:

@Entity
public class TemplatedDoc {

    @Id
    @Column(name = "DOC_ID")
    private Long docId;

    @OneToMany(mappedBy = "key.doc", cascade = CascadeType.ALL)
    @MapKey(name = "key")
    private Map<DocParameterBusinessKey, DocParameter> docParameters;

}


@Entity
public class DocParameter {

    @Id
    private String oid;

    @Embedded
    private DocParameterBusinessKey key;

}



@Embeddable
@Data
public class DocParameterBusinessKey {

    @ManyToOne
    @JoinColumn(name = "DOC_ID")
    private TemplatedDoc doc;

}

在服务器启动期间从休眠4迁移到5(在从jBoss EAP 6迁移到7.1.3的过程中)之后,我收到错误消息:

16:48:28,539 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 141) MSC000001: Failed to start service jboss.persistenceunit."some.ear/some-web.war#docPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."some.ear/some-web.war#docPU ": javax.persistence.PersistenceException: [PersistenceUnit: docPU] Unable to build Hibernate SessionFactory
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:195) [wildfly-jpa-7.1.3.GA-redhat-2.jar:7.1.3.GA-redhat-2]
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:125) [wildfly-jpa-7.1.3.GA-redhat-2.jar:7.1.3.GA-redhat-2]
       at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640) [wildfly-elytron-1.1.10.Final-redhat-1.jar:1.1.10.Final-redhat-1]
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:209) [wildfly-jpa-7.1.3.GA-redhat-2.jar:7.1.3.GA-redhat-2]
       at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_171]
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_171]
       at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_171]
       at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: docPU] Unable to build Hibernate SessionFactory
       at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:953) [hibernate-entitymanager-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:883) [hibernate-entitymanager-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
       at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:167) [wildfly-jpa-7.1.3.GA-redhat-2.jar:7.1.3.GA-redhat-2]
       ... 7 more
Caused by: java.lang.NullPointerException
       at org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy.foundCircularAssociation(AbstractLoadPlanBuildingAssociationVisitationStrategy.java:673) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributeDefinition(MetamodelGraphWalker.java:146) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributes(MetamodelGraphWalker.java:131) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCompositeDefinition(MetamodelGraphWalker.java:199) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCollectionIndex(MetamodelGraphWalker.java:230) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCollectionDefinition(MetamodelGraphWalker.java:207) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCollection(MetamodelGraphWalker.java:72) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.plan.build.spi.MetamodelDrivenLoadPlanBuilder.buildRootCollectionLoadPlan(MetamodelDrivenLoadPlanBuilder.java:54) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.<init>(AbstractLoadPlanBasedCollectionInitializer.java:62) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.collection.plan.CollectionLoader.<init>(CollectionLoader.java:81) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.collection.plan.CollectionLoader$Builder.byKey(CollectionLoader.java:74) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.collection.plan.AbstractBatchingCollectionInitializerBuilder.buildNonBatchingLoader(AbstractBatchingCollectionInitializerBuilder.java:28) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.loader.collection.BatchingCollectionInitializerBuilder.createBatchingOneToManyInitializer(BatchingCollectionInitializerBuilder.java:85) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.collection.OneToManyPersister.createCollectionInitializer(OneToManyPersister.java:513) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:664) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:466) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:423) [hibernate-core-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:880) [hibernate-entitymanager-5.1.14.Final-redhat-1.jar:5.1.14.Final-redhat-1]
       ... 9 more

没有

@OneToMany(mappedBy = "key.doc", cascade = CascadeType.ALL)
@MapKey(name = "key")
private Map<DocParameterBusinessKey, DocParameter> docParameters;

一切都开始,没有任何问题。 怎么了?

0 个答案:

没有答案