java - MongoDB / Morphia update operation for document with many fileds -


i have entity contains lets 20 different keys / local variable. in case want update doc , can use updateoperations in order perform query , have go filed filed , set new value new object.. if there way update current doc in db new fields

lets say:

   public class item {          @id         @getter         @setter         private objectid id;          @getter         @setter         private string itemid;          @getter         @setter         private string itemtitle; .. ..       } 

so lets have item stored, got new dto gui, of fields , rest null. want create generic update operation take non nullable values dto object , update in existing doc in db.

is possible?

i think so!

i see 2 possible ways:

alternative 1: can use reflection iterate every field in dto , put value copy of document recovered db. @ end of loop can update document.

alternative 2: update desired fields. mongo can update subset of fields in update operation: update data java driver


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -