corda - Corda 4.1:如何使用其嵌入对象中的字段查询 PersistentState?
问题描述
在我的代码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...
)
解决方案
当前无法使用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
推荐阅读
- docker - 在 GitLab 中使用 ElasticSearch,如果 ES Container 宕机了怎么办?
- android - 无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.android.volley:volley:1.1.1
- python - Python 2d 数组布尔减少
- ssis - 如何通过 SSIS 将所有表从 ODBC 源移动到 Access?
- postgresql - 有条件地更新 PostgreSQL 中 2 条记录中的值的有效方法
- swift - Swift:识别输入的字符是否按升序/降序排列
- javascript - 如何在 JSX 中重复一个元素?
- buildroot - 如何在包中使用 buildroot 进行自定义更改
- kubernetes - 服务在 Istio 服务网格中不通信
- google-apps-script - Google Apps 脚本的故障摘要:服务在一天内使用了过多的计算机时间