pulse00
pulse00

Reputation: 1314

Avoid overwriting mongodb documents with partially loaded entity from morphia

Morphia supports ignoring fields of loaded documents which can reduce the amount of data running over the wire when retrieving large documents significantly. There's a drawback tough: When loading a partial object, writing the same object back to mongoDB will overwrite any existing fields with empty values.

Is there a native morphia way to detect if a mongodb object was loaded partially, so one can avoid the overwriting scenario?

Upvotes: 0

Views: 127

Answers (1)

evanchooly
evanchooly

Reputation: 6233

Use Datastore.merge() rather than Datastore.save().

Upvotes: 1

Related Questions