Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
No EntryNotFoundException when trying to get with Key that have different parents
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
kimchy  
View profile  
 More options Apr 8, 11:43 pm
From: kimchy <kim...@gmail.com>
Date: Wed, 8 Apr 2009 20:43:46 -0700 (PDT)
Local: Wed, Apr 8 2009 11:43 pm
Subject: No EntryNotFoundException when trying to get with Key that have different parents
Hi,

  Assume I have two entities, entity1 and entity2. Entity1 and Entity2
have the same key value, but different parent key. Now, if I put
entity1, and do a get based on its key, I get the entity back. If I do
a get based on the second entity key (which is not stored), I also get
the entity back, where I assumed I wouldn't since they have different
parents. Here is code that simulates this:

        // different parents
        Key parent1 = KeyFactory.createKey("kind1", "parent1");
        Key parent2 = KeyFactory.createKey("kind1", "parent2");
        // same id value, different parent
        Key id1 = KeyFactory.createKey(parent1, "kind2", "id1");
        Key id2 = KeyFactory.createKey(parent2, "kind2", "id1");

        Entity entry1 = new Entity(id1.getKind(), id1.getName(),
parent1);
        Entity entry2 = new Entity(id2.getKind(), id2.getName(),
parent2);

        DatastoreService datastoreService =
DatastoreServiceFactory.getDatastoreService();
        datastoreService.put(entry1);

        // this should work fine
        Entity test = datastoreService.get(id1);
        System.out.println("Test1: " + test);
        // I expect to get a EntryNotFoundException, but nada, seems
to work
        test = datastoreService.get(id2);
        System.out.println("Test2: " + test);

What do you think?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Ross  
View profile  
 More options Apr 8, 11:50 pm
From: Max Ross <maxr+appeng...@google.com>
Date: Wed, 8 Apr 2009 20:50:12 -0700
Local: Wed, Apr 8 2009 11:50 pm
Subject: Re: [appengine-java] No EntryNotFoundException when trying to get with Key that have different parents

Yup, wrong and bad.  I actually found this bug yesterday about 3 hours
before launch but the horse was already out of the barn, so to speak.  The
good news is that, one, this problem is specific to the local environment.
When you deploy to prod this will work correctly.  We've fixed the problem
and it will be part of the next release that goes out.  The bad news is that
until then you're stuck with some really odd behavior in the local
environment.  The easiest workaround is to just use datastore-generated
keys, but I realize that may not be an option.

Max


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shay Banon  
View profile  
 More options Apr 9, 4:34 am
From: Shay Banon <kim...@gmail.com>
Date: Thu, 9 Apr 2009 11:34:41 +0300
Local: Thurs, Apr 9 2009 4:34 am
Subject: Re: [appengine-java] Re: No EntryNotFoundException when trying to get with Key that have different parents
ok, no problem. What are datastore generated keys? Are you referring
to JDO/JPA (which I don't use)?

p.s. I know its a tough question, but is there a chance that you can
estimate when the next release will come out?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Ross  
View profile  
 More options Apr 9, 1:41 pm
From: Max Ross <maxr+appeng...@google.com>
Date: Thu, 9 Apr 2009 10:41:53 -0700
Local: Thurs, Apr 9 2009 1:41 pm
Subject: Re: [appengine-java] Re: No EntryNotFoundException when trying to get with Key that have different parents

A com.google.appengine.api.datastore.Key can only have its id field or its
name field set, but not both.  When you create an Entity, you choose which
one.  If you use the Entity constructor that takes kind and name, the Key
that gets filled in when you insert the Entity will have its name field
set.  If you use the Entity constructor that just takes kind, the Key that
gets filled in when you insert the Entity will have its id field set, and
the value of the id field will have been generated by the datastore.  So,
since the datastore guarantees unique values for generated ids, if you let
the datastore generate all your ids you don't have to worry about this
(really annoying) problem.  Does that make sense?

I can't commit to a firm date for the next release at this point but I'd be
surprised if you didn't see something from us in the next week or two.

Max


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shay Banon  
View profile  
 More options Apr 9, 1:44 pm
From: Shay Banon <kim...@gmail.com>
Date: Thu, 9 Apr 2009 20:44:21 +0300
Local: Thurs, Apr 9 2009 1:44 pm
Subject: Re: [appengine-java] Re: No EntryNotFoundException when trying to get with Key that have different parents
Great, thanks!. In any case, I worked around most of the problems and
now you can do full text search on Google App Engine domain model
using Compass. More info here:
http://www.kimchy.org/searchable-google-appengine-with-compass/.

Cheers, and thanks for the help,
Shay


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Ross  
View profile  
 More options Apr 9, 3:11 pm
From: Max Ross <maxr+appeng...@google.com>
Date: Thu, 9 Apr 2009 12:11:49 -0700
Local: Thurs, Apr 9 2009 3:11 pm
Subject: Re: [appengine-java] Re: No EntryNotFoundException when trying to get with Key that have different parents

Great stuff!!!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google