【发布时间】:2018-03-01 18:16:43
【问题描述】:
此问题与此处发布的问题类似:Corda: error=org.hibernate.InstantiationException: No default constructor for entity
对于扩展 FungibleState 的自定义架构(如 API Vault Query documentation 中所述),我遇到了同样的错误:
object CustomSchemaV1 : MappedSchema(schemaFamily = CustomSchema.javaClass, version = 1, mappedTypes = listOf(PersistentCustomState::class.java))
{
@Entity
@Table(name = "custom_states", indexes = arrayOf(Index(name = "custom_field_idx", columnList = "custom_field")))
class PersistentCustomState(
/** Custom attributes */
@Column(name = "custom_field")
var customField: String? = null,
/** FungibleState parent attributes */
@Transient
val _participants: Set<AbstractParty>,
@Transient
val _owner: AbstractParty,
@Transient
val _quantity: Long,
@Transient
val _issuerParty: AbstractParty,
@Transient
val _issuerRef: OpaqueBytes
) : CommonSchemaV1.FungibleState(_participants?.toMutableSet(), _owner, _quantity, _issuerParty, _issuerRef.bytes)}
我安装了kotlin-jpa 插件。使所有字段为空似乎解决了扩展 PersistentState 的架构的问题,但由于 FungibleState 父字段数据类型,这里不是一个选项。
Corda 发布版本 = 2.0.0
【问题讨论】:
-
您是否尝试过创建一个没有参数的默认构造函数,它将空字符串、零等传递给父构造函数。比如:
constructor() : this("", "", "", "").