datastore.save() not returning correct representation of document in Mongo #3307
-
Hi, What is confusing me is that the datastore.save() method seems to just be returning the object that was passed in as it was, which means that the original, un-truncated OffsetDateTime is returned thus not reflective of what was stored in Mongo. It makes sense to me that morphia doesn't query Mongo to get the true representation for performance reasons, but I had assumed that it might apply the encode/decode methods from the (in my case custom) codec to the object in memory to ensure consistency. I assume this is expected behavior, I'm just wondering if theres an obvious solution I'm not aware of. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Correct. What is returned is the java object itself. it doesn't refresh its state from the database. If you want that exact state you can use the |
Beta Was this translation helpful? Give feedback.
Correct. What is returned is the java object itself. it doesn't refresh its state from the database. If you want that exact state you can use the
refresh()
method onDatastore
.