在我的代码中,contractId
属于PersistentDeal
,它是PersistentDealState
的嵌入式对象。 PersistentDealState
是DealState
的架构,它从ContractState
扩展。
如何获取DealState
并赋予contractId
作为查询条件的查询参数?
此查询条件不起作用
val result = builder {
val criteria = DealSchemaV1.PersistentDealState::deal.equal(DealSchemaV1.PersistentDeal::tcmContractID.equal(contractId))
val queryCriteria = QueryCriteria.VaultCustomQueryCriteria(expression = criteria, contractStateTypes = setOf(DealState::class.java),status = status)
vaultService.queryBy<DealState>(queryCriteria)
}
这是我的模特
@Entity
@Table(name = "DealState",
indexes = [Index(name = "contract_id_index", columnList = "contract_id")])
class PersistentDealState(
@Embedded
var deal: PersistentDeal
some other fields...
) : PersistentState()
@Embeddable
class PersistentDeal(
@Column(name = "contract_id")
var contractID: Long,
some other fields...
)
答案 0 :(得分:2)
当前无法使用VaultCustomQueryCriteria
为嵌入式对象指定可过滤条件。
请通过我们的GitHub网站提出一个问题(https://github.com/corda/corda/issues)来请求此问题。
当前可用的选项是使用JDBC会话: https://docs.corda.net/head/api-persistence.html#jdbc-session
或JPA实体管理器(和HQL): https://docs.corda.net/head/api-persistence.html#jpa-support