Prashant, please don't post multiple times for the same topic. Your answers are in this thread: http://groups.google.com/group/google-appengine-java/browse_thread/thread/2cd38dda7467d6fa
- Jason On Thu, Sep 17, 2009 at 8:32 AM, Prashant <antsh...@gmail.com> wrote: > hi, > > > I tried the "Updating an Object" (using detachable property) example given > here<http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Updating_an_Object>. > While experimenting with it I found that even if I do not add > *detachable="true" > *property to my JDO class it works without any problem. Is it ok to work > without detachable property or it just worked with my case? Following is the > code I tried : > > > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Data{ > @SuppressWarnings("unused") > @PrimaryKey > *...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)* > private Long id; > > @Persistent > private String value; > > public Data(String value){ > this.value = value; > } > > public void setValue(String value){ > this.value = value; > } > > public String getValue(){ > return this.value; > } > } > > > > > public class Main extends HttpServlet { > > public void doGet(HttpServletRequest req, HttpServletResponse resp) > throws IOException{ > doReq(req, resp); > } > > public void doPost(HttpServletRequest req, HttpServletResponse resp) > throws IOException{ > doReq(req, resp); > } > > private void doReq(HttpServletRequest req, HttpServletResponse resp) > throws IOException{ > Data data = new Data("some value"); > > *PersistenceManager pm = PMF.get().**getPersistenceManager(); > pm.makePersistent(data); // NOTE: i am not detaching the object > pm.close();* > > * chageValue(data);* > } > > @SuppressWarnings("unchecked") > private void chageValue(Data data){ > *PersistenceManager pm = PMF.get().**getPersistenceManager(); > data.setValue("some other value."); > pm.makePersistent(data); > pm.close();* > } > } > > > i want to fetch object(s) from datastore, cache it to Memcache and use the > same (cached object) for further uses (over requests). and if any change > happens to the object(s) i want to update the object(s) to datastore > straight away using cashed instance of object instead of fetching it (again) > form datastore and then updating it. following is a code snippet: > > ... > ... > Data data = *cache*.get("key"); > data.setValue("new updated value"); > pm.makePersistent(data); > *cache*.put("key", data); > ... > ... > ... > > is it necessary to add *detachable="true"* to my JDO class (Data) ? is it > necessary to detach object before caching to Memcache? is it required for my > JDO class (Data) to extend Serialzable Class? > > > Thanks. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 google-appengine-java@googlegroups.com To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---