java - allocateIds DatastoreService real-world usage -


can ask real world usages of datastoreservice

 - allocateidrange(keyrange range)  - allocateids(key parent, java.lang.string kind, long num)  - allocateids(java.lang.string kind, long num) 

uses of allocateids():

  1. you want write several mutually referential entities in transaction, using integer ids. wouldn't know "auto ids" (i.e., if leave id/name of key unset) until after commit, couldn't make entities "point each other" (e.g. using reference properties) part of txn. if allocate ids first, can manually set key ids allocated, write mutually referential entities in transaction, , without risk of collision other auto ids.

  2. you want user-facing ids human readable, e.g. case numbers. default auto ids large numbers (~16 decimal digit), allocateids() gives "old-style" sequential ids smaller (6 or 7 digits).

if entity wish allocate ids has ancestor, use function takes parent key arg. else, use other allocateids specify kind.

as allocateidrange(), recommend not use that. designed allow reserve block of integer id space own manual allocation, difficult , inefficient manage correctly on client side, , no longer supported (it fail on "new-style" large ids).


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -