Description
jpringle opened DATACOUCH-625 and commented
I've been experimenting with an optimal combination of Lombok annotations, generated identity fields and version support.
Along the way, I've found that if the identity field or the version field are immutable (and thus with() methods used for property updates) then the property updates applied during save() are not propagated back to the returned object instance.
This appears to be due to expecting the updates to be applied to the passed in object instance, but "withers" return new object instances which are dropped along the way.
Ie, in ReactiveUpsertByIdOperationSupport.one():
@Override public Mono<T> one(T object) {
return Mono.just(object).flatMap(o -> {
CouchbaseDocument converted = template.support().encodeEntity(o);
return template.getCollection(collection).reactive()
.upsert(converted.getId(),
converted.export(),
buildUpsertOptions()).map(result -> {
template.support().applyUpdatedCas(object, result.cas());
return o;
});
}).onErrorMap(throwable -> {
...
}
the object instance "o" (or "object") is never updated with the generated Id value or the result of "applyUpdatedCas()" if the property accessor results in a new object instance (as is the case with "wither" and final properties)
Referenced from: pull request #274
Backported to: 4.0.5 (Neumann SR5)