说我有以下域代码(此处使用mongodb,但适用于基于JPA的实体):
open class AggregateRoot (@Id open var id: String)
@Document
class Person(val firstName: String,
val lastName: String) : AggregateRoot(UUID.randomUUID().toString())
此模型可能会使用一段时间,并填充数据库。
然后我要向Person类添加一些字段:
open class AggregateRoot (@Id open var id: String)
@Document
class Person(val firstName: String,
val lastName: String,
val age: Int,
val address: Address,
val creditCard: CreditCard) : AggregateRoot(UUID.randomUUID().toString())
class Address(val street: String,
val postalCode: String,
val city: String)
class CreditCard(val number: String, val cvv: String, val expirationDate: String)
现在,我不再可以查询先前添加的实体,因为它们没有地址,年龄和信用卡所需要的数据。
在AggregateRoot类中是否可以使用id的val? val时出现异常:
没有访问者可以设置属性@ org.springframework.data.annotation.Id()私有最终java.lang.String com.github.mgrzeszczak.nosqldddaggregates.AggregateRoot.id!