我正在尝试从保管库查询状态而不使用状态的线性ID,而是使用模式中存在的Int(唯一)变量
val sNumber = AState.ASchemaV1.AEntity::SNumber
val QueryCriteria = QueryCriteria.VaultCustomQueryCriteria(sNumber.equal(SalesNumber))
val StateAndRef = serviceHub.vaultService.queryBy<AState>(QueryCriteria).states.single()
val outState = StateAndRef.state.data
查询条件没有引发任何错误,但是我也没有得到任何输出,但是在调试时我得到了错误响应
javax.persistence.PersistenceException: org.hibernate.InstantiationException: No default constructor for entity: AState.ASchemaV1.AEntity
但是我已经定义了函数中的所有列。我想念什么? 这是Schema的代码
override fun supportedSchemas() = listOf(ASchemaV1)
override fun generateMappedObject(schema: MappedSchema) = ASchemaV1.AEntity(this)
object ASchemaV1 : MappedSchema(AState::class.java, 1, listOf(AEntity::class.java)) {
@Entity
@Table(name = "Table")
class AEntity(A: AState) : PersistentState() {
@Column
var CONumber: String = A.linearId.id.toString()
@Column
var SalesNumber: Int = A.SalesNumber
@Column
var ProductID: Int = A.ProductID
@Column
var Quantity: Int = A.Quantity
@Column
var Rate: Double = A.Rate
@Column
var DeliveryDate: Date = A.DeliveryDate
@Column
var DeliveryLocation: String = A.DeliveryLocation
@Column
var Status: String = A.Status.toString()
}
}
答案 0 :(得分:0)
AState.ASchemaV1缺少构造函数。
object ASchemaV1 : MappedSchema(AState::class.java, 1, listOf(AEntity::class.java)) {
@Entity
@Table(name = "Table")
class AEntity(
@Column
var CONumber: String,
@Column
var SalesNumber: Int,
@Column
var ProductID: Int,
@Column
var Quantity: Int,
@Column
var Rate: Double,
@Column
var DeliveryDate: Date,
@Column
var DeliveryLocation: String,
@Column
var Status: String
): PersistentState() {
constructor(A: AState): this(A.linearId.id.toString(), A.SalesNumber, A.ProductID, A.Quantity, A.Rate, A.DeliveryDate, A.DeliveryLocation, A.Status.toString())
}
}