我是R3 Corda的新手。我一直陷入这个问题。我试图找出这个问题已经花费了几个小时。我在运行节点时得到了Hibernate AnnotationException
。这是我的架构声明文件NewIndicationSchema.java
。
package com.myproject.schema;
import com.google.common.collect.ImmutableList;
import net.corda.core.schemas.MappedSchema;
import net.corda.core.schemas.PersistentState;
import org.hibernate.annotations.Cascade;
import javax.persistence.*;
import org.hibernate.annotations.CascadeType;
import java.util.Date;
/**
* The family of schemas for NewIndication.
*/
public class NewIndicationSchema extends MappedSchema {
public NewIndicationSchema() {
super(NewIndicationSchema.class, 1, ImmutableList.of(Indication.class));
}
@Entity
@Table(name = "new_indications", uniqueConstraints = {@UniqueConstraint(columnNames = "indicationNo")})
public static class Indication extends PersistentState {
@Column(name = "_id", unique = true, nullable = false) private final String _id;
@Column(name = "indicationNo") private final String indicationNo;
@Column(name = "status") private final String status;
@Column(name = "effDate") private final Date effDate;
@Column(name = "programID") private final String programID;
@OneToOne(fetch = FetchType.LAZY, targetEntity = Insured.class)
/*@JoinColumns(@JoinColumn(name = "transaction_id", referencedColumnName = "transaction_id"))*/
@Cascade(value = CascadeType.PERSIST)
private final Insured insured;
public Indication(Indication indication){
this._id = indication.get_id();
this.indicationNo = indication.getIndicationNo();
this.status = indication.getStatus();
this.insured = indication.getInsured();
this.effDate = indication.getEffDate();
this.programID = indication.getProgramID();
}
public String get_id() {
return _id;
}
public String getIndicationNo(){
return this.indicationNo;
}
public String getStatus(){
return this.status;
}
public Date getEffDate(){
return this.effDate;
}
public Insured getInsured(){
return this.insured;
}
public String getProgramID() {
return programID;
}
}
@Entity
@Table(name = "insureds")
class Insured {
@OneToOne(mappedBy = "new_indications")
private final Indication indication;
@Column(name = "name") private final String name;
@Column(name = "dba") private final String dba;
@Column(name = "city") private final String city;
@Column(name = "address1") private final String address1;
@Column(name = "address2") private final String address2;
@Column(name = "state") private final String state;
@Column(name = "zip") private final String zip;
public Insured(Indication indication, String name, String address1, String address2, String city, String state, String zip, String dba) {
this.indication = indication;
this.name = name;
this.dba = dba;
this.address1 = address1;
this.address2 = address2;
this.city = city;
this.state = state;
this.zip = zip;
}
// Getters
public Indication getIndication() {
return indication;
}
public String getName(){
return this.name;
}
public String getDba(){
return this.dba;
}
public String getAddress1(){
return this.address1;
}
public String getAddress2(){
return this.address2;
}
public String getCity(){
return this.city;
}
public String getState(){
return this.state;
}
public String getZip(){
return this.zip;
}
}
}
我能够毫无例外地进行构建,但是当我尝试运行节点时,我将以下错误记录到节点的命令提示符下。我一直在尝试通过Internet进行的所有解决方案,但是它们都与Corda
没有关系。它们都仅与Hibernate
相关。我觉得我缺少Corda
中的任何特殊注释,或者我认为该模式是错误的。请帮助我。
E 02:01:26+0530 [main] internal.Node.run - Exception during node startup {}
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.myproject.schema.NewIndicationSchema$Indication.insured references an unknown entity: com.myproject.schema.NewIndicationSchema$Insured
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:97) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processEndOfQueue(InFlightMetadataCollectorImpl.java:1752) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processFkSecondPassesInOrder(InFlightMetadataCollectorImpl.java:1696) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1583) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration.buildSessionFactory(HibernateConfiguration.kt:105) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration.makeSessionFactoryForSchemas(HibernateConfiguration.kt:63) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration.access$makeSessionFactoryForSchemas(HibernateConfiguration.kt:26) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration$sessionFactoryForSchemas$1.apply(HibernateConfiguration.kt:44) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration$sessionFactoryForSchemas$1.apply(HibernateConfiguration.kt:26) ~[corda-node-api-3.2-corda.jar:?]
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source) ~[?:1.8.0_181]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration.sessionFactoryForSchemas(HibernateConfiguration.kt:44) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.HibernateConfiguration.<init>(HibernateConfiguration.kt:40) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence$hibernateConfig$2$1.invoke(CordaPersistence.kt:64) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence$hibernateConfig$2$1.invoke(CordaPersistence.kt:51) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:136) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:124) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:131) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence$hibernateConfig$2.invoke(CordaPersistence.kt:63) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence$hibernateConfig$2.invoke(CordaPersistence.kt:51) ~[corda-node-api-3.2-corda.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) ~[kotlin-stdlib-1.1.60.jar:1.1.60-release-55 (1.1.60)]
at net.corda.nodeapi.internal.persistence.CordaPersistence.getHibernateConfig(CordaPersistence.kt) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.getEntityManagerFactory(CordaPersistence.kt:67) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.DatabaseTransaction$sessionDelegate$1.invoke(DatabaseTransaction.kt:31) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.DatabaseTransaction$sessionDelegate$1.invoke(DatabaseTransaction.kt:16) ~[corda-node-api-3.2-corda.jar:?]
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:130) ~[kotlin-stdlib-1.1.60.jar:1.1.60-release-55 (1.1.60)]
at net.corda.nodeapi.internal.persistence.DatabaseTransaction.getSession(DatabaseTransaction.kt) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.node.services.network.PersistentNetworkMapCache$start$$inlined$synchronized$lambda$1.invoke(PersistentNetworkMapCache.kt:99) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.services.network.PersistentNetworkMapCache$start$$inlined$synchronized$lambda$1.invoke(PersistentNetworkMapCache.kt:75) ~[corda-node-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:136) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:124) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:131) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.node.services.network.PersistentNetworkMapCache.start(PersistentNetworkMapCache.kt:99) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode$start$4.invoke(AbstractNode.kt:207) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode$start$4.invoke(AbstractNode.kt:105) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode$initialiseDatabasePersistence$2.invoke(AbstractNode.kt:685) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode$initialiseDatabasePersistence$2.invoke(AbstractNode.kt:105) ~[corda-node-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:152) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:138) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:124) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:131) ~[corda-node-api-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode.initialiseDatabasePersistence(AbstractNode.kt:684) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.Node.initialiseDatabasePersistence(Node.kt:345) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:206) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.Node.start(Node.kt:359) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:145) ~[corda-node-3.2-corda.jar:?]
at net.corda.node.internal.NodeStartup.run(NodeStartup.kt:115) [corda-node-3.2-corda.jar:?]
at net.corda.node.Corda.main(Corda.kt:13) [corda-node-3.2-corda.jar:?]
答案 0 :(得分:1)
您需要在构造函数中包含要引用的所有Schema实体:
super(NewIndicationSchema.class, 1, ImmutableList.of(Indication.class, Insure.class));