Description
Knut Schleßelmann opened DATAMONGO-2229 and commented
Currently I'm struggling with the design of some aggregates in kotlin.
I'd like to have a collection exposed as a property but I need the mutable collection to handle things internally. AFAIK the current way to go in kotlin would be
@Document
class Product(
@Id val id: String,
attributes: Set<String> = emptySet()
) {
private val _attributes: MutableSet<String> = attributes.toMutableSet()
val attributes: Set<String>
get() = _attributes
}
Sadly this fails because Spring Data Mongo cannot bind the document to my class any more. Even if I annotate _attributes
with @Field("attributes")
the constructor parameter is only used to determine the property field name (which then doesn't match again).
I'd be great to have better support for such use cases which do not involve hacks using the @Value("#root...")
on properties or naming constructor arguments like some internal private field
Affects: 2.1.5 (Lovelace SR5)