Reputation: 103
I am trying to query a state from vault without using the linear Id of the state and instead an Int(unique) variable present in Schema
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
The Query criteria is not throwing any error but I am also not getting any output but on debugging I got an error response
javax.persistence.PersistenceException: org.hibernate.InstantiationException: No default constructor for entity: AState.ASchemaV1.AEntity
but I have defined all the columns in the function. What am I missing? Here is code for 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()
}
}
Upvotes: 1
Views: 313
Reputation: 364
AState.ASchemaV1 is missing the constructor.
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())
}
}
Upvotes: 1