作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在Corda V3中,我们按照API Vault Query文档中的描述扩展了FungibleState
:
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)}
_quantity
父字段(按
custom_field
分组)?
QueryCriteria
:
val sum = builder {
CustomSchemaV1.PersistentCustomState::_quantity.sum(
groupByColumns = listOf(
CustomSchemaV1.PersistentCustomState::customField
),
orderBy = Sort.Direction.ASC
)
}
return QueryCriteria.VaultCustomQueryCriteria(sum)
Unable to locate Attribute with the the given name [_quantity] on this ManagedType [net.corda.core.schemas.PersistentState]
@Transient
注释,该注释也将
quantity
保留在子类上,但是这导致在数据库中存储重复的值。
最佳答案
您是否考虑过尝试以下方法:
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 */
participants: MutableSet<AbstractParty>?,
owner: AbstractParty,
quantity: Long,
issuerParty: AbstractParty,
issuerRef: OpaqueBytes
) : CommonSchemaV1.FungibleState(participants, owner, quantity, issuerParty, issuerRef.bytes)}
quantity
列?
CommonSchemaV1.FungibleState
是
MappedSuperclass
,因此其列将映射到子实体中。
关于hibernate - 将子类按自定义FungibleState模式的瞬时父属性分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49511406/
我是一名优秀的程序员,十分优秀!