Thiago,

Nowadays the amount of documentation and features of both interfaces are
almost equals. Java has some characteristics that Python doesn't and
vice-versa.

But let's cope with your problem, the solution given by "objectuser" is
valid and should work fine, the only problem is that you'll never be able to
use transactions if the entities are not in the same entity group.

A middle term between querying the real entity and just refering the id of
it is to query and persist just the Key through:

Query q = new Query("User").setKeysOnly();


Combined with the filter that you may want and after that asking the
datastore service (because I haven't found any hook in the JDO API to ask
for the keys) for the keys and using it as the argument to your new
LoginHistory entity.

And your english is not bad. Bwt, I'm brazilian too! :)

*Jayr Motta*
Software Developer
*
*
I'm  on 
BlackBeltFactory.com<http://www.blackbeltfactory.com/ui#!User/jmotta/ref=jmotta>
!



On Mon, Jul 4, 2011 at 11:54 AM, Thiago <thiagorossi...@gmail.com> wrote:

> Hi.
>
> I'm using Google App Engine and I really liked it. It was a bit
> difficult in the beginning because there are more documentation for
> Python and I only know Java but now I think I'm going well.
>
> I'm using JDO and I understand that do add a child to a one to many
> relationship I need to do this:
>
> User user = pm.getObjectById(User.class.getName(), "thiago");
> LoginHistory loginHistory = new LoginHistory(now);
> loginHistory.setKey(user.getKey().getChild(LoginHistory.class.getName(),
> now.getTime());
> user.getLoginHistory(loginHistory);
> pm.close();
>
> I loginHostory has to have User as the parent, so User("thiago")/
> LoginHistory([time]). I can't do makePersistent(myChild) because it
> won't appear in the collection or anywhere with user, so I don't know
> how JDO makes the link with the collection because I can't see in the
> Datastore Viewer.
>
> But my real question is: I have an entity and the collection is really
> big, like user.getLoginHistory(), and I think after a lot of logins it
> will be wrong to retrieve this collection just to add a new child.
> Isn't there any way to create a child in a collection without using
> the parent? Something like makePersistent(newChild) and newChild have
> the key like I said? Or how can I do this using Datastore (low level
> API)? I can't see the property with the collection in the Datastore
> viewer.
>
> Thank you very much.
>
> PS: Sorry for my English, I'm brazilian.
>
> --
> 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.
>
>

-- 
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.

Reply via email to