ok, so it appears the best way is to query the key only.  I have set
it up to do that, except now I'm having an issue where the parent
object is not storing the child's key.

Below is to show how I set up my classes to save a reference to the
child classes

@PersistenceCapable
class parent {
@PrimaryKey
@Persistent
Key key;

//other private variables

@Persistent
Key childKey;
}

The issue is that when I make the parent class persistent, for some
reason the child key becomes null.  It is set in the constructor as
the value of the child's key (I call a static method to create the
child object then return the key).  I know the key returned is not
null through some debugging.

Why would a persistent Key stay transient?  The docs say that Keys are
persistent capable



On Dec 21, 4:32 pm, Mike <[email protected]> wrote:
> You can query the key only, hope this helps.
>
> http://code.google.com/appengine/docs/python/datastore/queriesandinde...
>
> On Dec 21, 8:51 pm, Jess Evans <[email protected]> wrote:
>
>
>
> > Be wary of a try/get/catch/persist combo.  I was doing this initially, but
> > found it triggered a memory leak.  I resorted to a query by business key.  I
> > can't confirm whats most efficient.  It's certainly not in terms of index
> > storage overhead.  I just wanted to throw out the warning.
>
> > On Dec 21, 2009 12:08 PM, "t3jem" <[email protected]> wrote:
>
> > Ok,
>
> > So I'm writing my first game using the Google App Engine and have been
> > finding that using RPC and the datastore is much different than I'm
> > use to.  I've managed to get along, but I'm pretty stuck on this one,
> > I can't find it anywhere.
>
> > My problem is, I need to be able to create a new object with a unique
> > ID when a new user logs into the game.  I was doing this by randomly
> > generating a key and then using a query to the datastore to retrieve
> > an object by that ID.  If nothing turns up then I persist the new
> > object with that ID.  I understand that with an exceedingly great
> > amount of users this method could become a bit slow, but I don't
> > intend to have more than 1000 objects of this type in the datastore so
> > I don't foresee any problems with this method (please tell me if I'm
> > terribly mistaken).
>
> > I get my error when I go to attempt a retrieval of the missing object
> > from the datastore.  I use PersistenceManager.getObjectById(foo.class,
> > Key)
>
> > when my program reaches the call it throws a
> > NucleusObjectNotFoundException.  I understand this is probably normal
> > behavior, the problem is, I can't seem to find a way to check if the
> > key already exists in the datastore or not.
>
> > Is there a cheap way to check for a key? the only other method I can
> > think of is to get a collection of all the objects of that class and
> > check the created key against all existing ones, but that seems much
> > to expensive.
>
> > Thank you for your time
>
> > --
>
> > 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%2B 
> > [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.


Reply via email to