Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Amit Pandey
*@Simon : *Ok. so here we are talking about Updating a One-to-one child. Take a example of one to many owned relation. Class A{ long id; List strings; } Suppose object of *A* class is already inserted in datastore. Now I want to update the object by changing the *strings* value. My requirement

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Simon Knott
What's the point in keeping the old object? It's tied into the Entity Group via its key anyway, it just becomes orphaned and as far as I know inaccessible. -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, s

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Luca Matteis
Oh! Oh!!! Great idea I will just edit it instead of creating a new one! DUH! thanks so much On Fri, Apr 8, 2011 at 11:53 AM, Simon Knott wrote: > Is there any reason you make a new MyImage object?  Why can't you just > change the MyImage object which already exists in the MyUser object? > > -

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Amit Pandey
But editing the existing one is not a good solution. What if I want to insert another object keeping old object remains on datastore? On Fri, Apr 8, 2011 at 4:04 PM, Luca Matteis wrote: > Oh! Oh!!! Great idea I will just edit it instead of creating a new > one! DUH! thanks so much > > On Fri

[appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Ian Marshall
Have you looked at the GAE persistence blog of Max Ross of Google? There are some excellent working examples there... I have found it useful whilst working through my own private JDO nightmare! On Apr 8, 10:49 am, Luca Matteis wrote: > Argh! Nothing! I just tried making all changes... nothing..

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Luca Matteis
Argh! Nothing! I just tried making all changes... nothing.. same results :( It's incredible I can't find any example online that involves editing a child owned entity. On Fri, Apr 8, 2011 at 11:41 AM, Simon Knott wrote: > I've no idea whether it makes any difference, but try changing the > follow

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Simon Knott
Is there any reason you make a new MyImage object? Why can't you just change the MyImage object which already exists in the MyUser object? -- 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 googl

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Simon Knott
I've no idea whether it makes any difference, but try changing the following: @Persistent private MyImage avatar; to @Persistent(defaultFetchGroup = "true") private MyImage avatar; -- You received this message because you are subscribed to the Google Groups "Google App Engin

[appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Ian Marshall
Hi Luca, My comments, for what they are worth, in ascending order of importance: 1. In your two MyUser public static methods, it might be good practice to close the PersistenceManager instance before returning. 2. For the annotation for persistent entity classes, I use: @PersistenceCapable(

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Luca Matteis
The MyUser entity: http://codepad.org/C2qRTTRt and the MyImage entity: http://codepad.org/xR6hhuU8 On Fri, Apr 8, 2011 at 11:00 AM, Simon Knott wrote: > Can you post the code for your MyUser and the MyImage classes as well? > > -- > You received this message because you are subscribed to the G

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Simon Knott
Can you post the code for your MyUser and the MyImage classes as well? -- 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, sen

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Luca Matteis
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 stil

[appengine-java] Re: JDO - Updating a One-to-one child

2011-04-08 Thread Ian Marshall
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 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 adde

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
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 wrote: > Do you use transactions? > > Instead of your > >  PersistenceManager pm = PMF.get().getPe

[appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Ian Marshall
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().getPersistenc

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
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 wrote: > Well, I would think the Key has rela

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
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 wrote: >

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Simon Knott
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 recei

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
I don't see the actual Recipe being update with anything. I just see the Image being added in the Image 'table'. But from the datastore viewer there's no attribute in the Recipe 'table'. Hope that's clear. On Thu, Apr 7, 2011 at 10:58 AM, Simon Knott wrote: > If you look in the datastore admin to

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
It's the same when deployed to GAE. From the live datastore viewer I don't see the children when viewing the Recipe entity itself. The images get stored in another table called Image. Was I suppose to see a reference to the image object directly in the Recipe entity? On Thu, Apr 7, 2011 at 11:08 A

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Simon Knott
Have you tried deploying to GAE? You can only see child fields in the datastore viewer in Production. -- 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

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Simon Knott
If you look in the datastore admin tool, can you see whether the Recipe is being updated with the new image reference? Are you seeing this problem on Dev or Prod? -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this g

Re: [appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Luca Matteis
Hello Simon, even if I persist it doing try { r.setImage(newImage); pm.makePersistent(newImage); } finally { pm.close(); } I still get the same results. The interesting thing is that if I delete the image entity from the datastore, the recipe

[appengine-java] Re: JDO - Updating a One-to-one child

2011-04-07 Thread Simon Knott
Hi, I don't personally use JDO, but don't you have to re-put your object? I don't know how JDO does its dirty checking - I doubt very much that it will persist modified entities just because you're closing the Persistence Manager. Cheers, Simon -- You received this message because you are