google-code-export / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
1 stars 0 forks source link

possible logical bug during key creation #43

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I discovered a sneaky bug, which can happen due to a developer's mistake.

class Party {
@Id Long id
....
}

In one of my UI screens, I do a post of id (from the above Party), and on the 
server, that
'id' is received as a String.  Hence, the Party key can be created using String 
id.
Key<party> key = new Key(Party.class, id)
ofy.get(key)
I will never get the Party entity back, because the Party was creating using 
the long id.

The Keys constructed with 'String id' and 'long id' are different.

Can any error checking be done while creating the Objectify Key.

Original issue reported on code.google.com by aswath.s...@gmail.com on 23 Jun 2010 at 1:58

GoogleCodeExporter commented 9 years ago
Adding to the issue...
What, if the key is created using string id instead of long id, and then the 
key is stored in other entities.

So, it is better to do proper checking during Key creation.

As someone was pointing in the group, on how to introduce more logic in 
GWT-Safe objects.  An interface can be introduced that validates the key 
creation logic.  The interface then could be safely sent in GWT safe class.

Original comment by aswath.s...@gmail.com on 23 Jun 2010 at 2:04

GoogleCodeExporter commented 9 years ago

Original comment by lhori...@gmail.com on 30 Jun 2010 at 1:55