Affects Version/s: 2.1.10 (Lovelace SR10)
Fix Version/s: 2.2 RC3 (Moore)
After updating from 2.0.x to 2.1.10, we noticed that the new value of a field annotated with the @LastModifiedDate annotation is not persisted, in case of Kotlin data classes.
Please, consider the following data class:
and the following use case:
Now, updated.modificationDate is updated and points to a correct point of time, but fetched.modificationDate is has the old value and is the same as inserted.modificationDate.
When the field is var instead of val then the new value of modificationDate is persisted, and fetched.modificationDate has the expected value.
Adding a wither doesn't change much, and the field is not persisted, too.
I prepared a minimal, example project that shows the issue here.
Also, I noticed that in ReactiveMongoTemplate::doSaveVersioned the annotated field is changed, but then the old value is persisted:
If this is indeed a bug, I would like to take a deeper look at it, and prepare a PR with a fix.