With the low-level API, you would just set the Key of the old object to the one one and persist it. With managed persistence via PersistenceManager or EntityManager, I believe you can set a key and merge (but I'm not sure off the top of my head).
On Wed, Sep 8, 2010 at 12:43 PM, Shaun <[email protected]> wrote: > This might be very obvious, but imagine you have an object in the > datastore that you simply want to to replace with another, i.e. keep > the same key, just replace all the field values. Is there any easy way > to do this without setting each field value of the datastore object > with field values of the other object? > > As an example I find myself doing this alot: > > ExpenseEntry lJsonExpenseEntry = gson.fromJson(pExpenseEntryJson, > ExpenseEntry.class); > ExpenseEntry lExpenseEntry = > pm.getObjectById(ExpenseEntry.class, > expenseKey); > > > lExpenseEntry.setExpenseamount(lJsonExpenseEntry.getExpenseamount()); > > lExpenseEntry.setExpensecategory(lJsonExpenseEntry.getExpensecategory()); > > lExpenseEntry.setExpensedate(lJsonExpenseEntry.getExpensedate()); > > lExpenseEntry.setExpensename(lJsonExpenseEntry.getExpensename()); > > lExpenseEntry.setExpensenotes(lJsonExpenseEntry.getExpensenotes()); > > lExpenseEntry.setExpenseuser(lJsonExpenseEntry.getExpenseuser()); > > lExpenseEntry.setProjectid(lJsonExpenseEntry.getProjectid()); > > in order to update the datastore object, ideally I could do this all > in a few lines by simply replacing the current datastore object with > the new one. Maybe just removepersistence and then add it again? > Thanks for the thoughts. > > Shaun > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > -- Ikai Lan Developer Programs Engineer, Google App Engine Blog: http://googleappengine.blogspot.com Twitter: http://twitter.com/app_engine Reddit: http://www.reddit.com/r/appengine -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
