Domanda

I have an AppEngine Project which uses Objectify.

  • I just upgraded my AppEngine SDK => 1.9.2
  • And I migrated from Objectify 3.1 to 4.1.2

Before that switch, the generated IDs of my entities in the DataStore where in that range :

  • id = 84001
  • id = 86001 etc.

Now they are like this :

  • id = 5105650963054592
  • id = 5649050225344512 etc.

The previous IDs were already a bit strange (big gaps) but it seems normal, now there might be something wrong.

Where could be the problem ?

  • My code / Config ?
  • Objectify ?
  • DataStore ?
  • Nothing, it's normal

Nb : I don't set the ID (type Long) before calling ofy().save().entity(entity).now().

Thanks for your help.

Pierre.

È stato utile?

Soluzione

This is the correct behavior. App Engine switched to long and random auto-generated IDs in order to reduce contention (and, therefore, improve the performance) in the Datastore.

The Datastore can be configured to generate auto IDs using two different auto id policies: The default policy generates a random sequence of IDs that are approximately uniformly distributed. Each ID can be up to 16 digits long. The legacy policy creates a sequence of non-consecutive smaller integer IDs.

Source: Entities, Properties, and Keys

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top