Closed Doraemoe closed 8 months ago
MongoDB truncates the precision to milliseconds as MongoDB uses millisecond precision in their temporal data types. Newer Java versions have introduced nano-second precision to Instant
and other temporal types so this isn't really something we can fix. We also do not plan to load the object after saving it as it would significantly change application and performance behavior.
If you require the WYSIWYG perspective on your object, we suggest you either load the entity after saving it or provide an EntityCallback
that truncates instants to milliseconds.
Thanks, I will try use workaround instead.
However, shouldn't the document also make it clear since the return is not exactly the saved object
?
There are many ways to affect either the written Document
(converters, entity callbacks, lifecycle events) or the entity without reflecting those changes in the other one.
Hi,
In the document for
ReactiveMongoOperations.save(T)
method, it says the returned object of this method is the saved object. However, if the saved object containsInstant
field, the value of the saved object this method returns will be different from the actual saved object in MongoDB.e.g. let's consider a simple db model
Then a simple test
This is probably because MongoDB provides only millisecond-precision according to this comment If that's the case, shouldn't saved object also returns millisecond-precision?
In addition, when check saved object with other application like mongosh/MongoDB Compass, it shows the saved object time only contains 3 digit precision too.
Am I missing something here? Thanks.