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);
// 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);
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.
On Wed, Apr 8, 2009 at 8:43 PM, kimchy <kim...@gmail.com> wrote:
> 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);
> // 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);
On Thu, Apr 9, 2009 at 6:50 AM, Max Ross <maxr+appeng...@google.com> wrote:
> 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
> On Wed, Apr 8, 2009 at 8:43 PM, kimchy <kim...@gmail.com> wrote:
>> 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);
>> // 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);
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.
On Thu, Apr 9, 2009 at 1:34 AM, Shay Banon <kim...@gmail.com> wrote:
> 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?
> On Thu, Apr 9, 2009 at 6:50 AM, Max Ross <maxr+appeng...@google.com<maxr%2Bappeng...@google.com>>
> wrote:
> > 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
> > On Wed, Apr 8, 2009 at 8:43 PM, kimchy <kim...@gmail.com> wrote:
> >> 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:
> >> // 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);
On Thu, Apr 9, 2009 at 8:41 PM, Max Ross <maxr+appeng...@google.com> wrote:
> 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
> On Thu, Apr 9, 2009 at 1:34 AM, Shay Banon <kim...@gmail.com> wrote:
>> 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?
>> On Thu, Apr 9, 2009 at 6:50 AM, Max Ross <maxr+appeng...@google.com>
>> wrote:
>> > 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
>> > On Wed, Apr 8, 2009 at 8:43 PM, kimchy <kim...@gmail.com> wrote:
>> >> 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:
>> >> // 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);
> On Thu, Apr 9, 2009 at 8:41 PM, Max Ross <maxr+appeng...@google.com<maxr%2Bappeng...@google.com>>
> wrote:
> > 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
> > On Thu, Apr 9, 2009 at 1:34 AM, Shay Banon <kim...@gmail.com> wrote:
> >> 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?
> >> On Thu, Apr 9, 2009 at 6:50 AM, Max Ross <maxr+appeng...@google.com<maxr%2Bappeng...@google.com>
> >> wrote:
> >> > 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
> >> > On Wed, Apr 8, 2009 at 8:43 PM, kimchy <kim...@gmail.com> wrote:
> >> >> 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:
> >> >> // 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);