I hate to be the dork that argues with the referees, but I'm not fond
of this advice...

 * long-id keys can be user-defined just as easily as string-name
keys, so you can enforce uniqueness constraints either way if you have
some sort of natural key.

 * Readable urls are a high level construct, and it's easy enough to
use pretty names mapped to ids using the memcache.  If you ever want
to be able to rename people, you probably shouldn't use their name as
a key!

I'd say that the use case of string name vs numeric id is...  is your
id a number or is it a string?  Boring answer but seems to sum it up
pretty well.

Jeff

On Mon, Feb 22, 2010 at 10:50 AM, Max Ross (Google)
<maxr+appeng...@google.com> wrote:
> 1) Readable-urls.  http://yourapp.appspot.com/users/max versus
> http://yourapp.appspot.com/users/192398411324987
>
> 2) The datastore doesn't support uniqueness constraints so a user-defined
> key is the only way you can do a true createIfNonExistent() method:
>
> beginTxn();
> Entity e;
> try {
>   e = lookupByKeyName(keyName);
> } cath (EntityNotFoundException enfe) {
>   e = createNewEntity(keyName);
> }
> commitTxn();
>
> The final line throws ConcurrentModificationException if someone else
> created an entity with the same keyName in between the lookup and the
> commit.
>
> Max
> On Sun, Feb 21, 2010 at 5:08 PM, DutrowLLC <dutrow...@gmail.com> wrote:
>>
>> Hi,
>>
>> What is the intended purpose of keyName when creating a new Key or new
>> Entity in the low-level API?  What are the proper use cases for
>> keyName?
>>
>> Thanks!
>>
>> Chris
>>
>> --
>> 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-j...@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-j...@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-j...@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