Here's the entire piece of code that handles the update. I changed it to setAvatar() (line 42) and it's on a `MyUser` object instead of a Recipe, but it's the same thing:
http://codepad.org/qPo2ZyBX I also update the 'name' of the user, and the update works fine... just as I said, the object still points to the first image instead of the one added. On Fri, Apr 8, 2011 at 10:11 AM, Ian Marshall <[email protected]> wrote: > Hi Luca, > > What's your code for > > r.setImage(newImage) > > and anything else that might be relevant? > > Ian > > > > On Apr 7, 4:25 pm, Luca Matteis <[email protected]> wrote: >> Hello Ian, I tried using your exact piece of code. Still same results. >> The recipe still points to the first image instead of the most >> recently added one. >> >> On Thu, Apr 7, 2011 at 5:20 PM, Ian Marshall <[email protected]> >> wrote: >> > Do you use transactions? >> >> > Instead of your >> >> > PersistenceManager pm = PMF.get().getPersistenceManager(); >> > Recipe r = pm.getObjectById(Recipe.class, recKey); >> > try >> > { >> > r.setImage(newImage); >> > } >> > finally >> > { >> > pm.close(); >> > } >> >> > have you tried >> >> > PersistenceManager pm = PMF.get().getPersistenceManager(); >> > Transaction tx = pm.currentTransaction(); >> > try >> > { >> > tx.begin(); >> >> > Recipe r = pm.getObjectById(Recipe.class, recKey); >> > r.setImage(newImage); >> >> > tx.commit(); >> > } >> > finally >> > { >> > try >> > { >> > if (tx.isActive()) // Because of an exception, say >> > tx.rollback(); >> > } >> > finally >> > { >> > pm.close(); >> > } >> > } >> >> > On Apr 7, 3:03 pm, Luca Matteis <[email protected]> wrote: >> >> This is really weird. I cannot find anything on the internet that >> >> could help me. It seems such a simple thing to be editing child >> >> objects and I find it ridiculous that I can't find a solution. >> >> >> please help >> >> >> On Thu, Apr 7, 2011 at 11:53 AM, Luca Matteis <[email protected]> wrote: >> >> > Well, I would think the Key has relationship information. The thing is >> >> > that I'm able to fetch the image for the recipe, so the relationship >> >> > is there somehow. It seems as if setImage() isn't enough for the >> >> > linkage to update to the latest image. >> >> >> > On Thu, Apr 7, 2011 at 11:29 AM, Simon Knott <[email protected]> >> >> > wrote: >> >> >> Yes, that's what I would have expected - how else would a recipe ever >> >> >> retain >> >> >> which image it is related to? Is the relationship purely stored >> >> >> within the >> >> >> key of the Image? >> >> >> >> I must admit that without any knowledge of JDO and its relationship >> >> >> management, I'm just making wild guesses! >> >> >> >> -- >> >> >> 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. >> >> > -- >> > 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 >> > athttp://groups.google.com/group/google-appengine-java?hl=en. >> >> > > -- > 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. > > -- 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.
