App Engine 是否自动生成 Long @id 在实体范围内是唯一的?

Is appengine auto generated Long @id unique within entity scope?

使用 objectify,我使用 App Engine 自动生成的 ID 为我的实体创建 ID,如下所示:

@id
Long ID;

我在变量 ID 中输入了 null,因此 App Engine 会自动为我的实体生成 ID。

通过对象化函数创建密钥:

Key.create(java.lang.Class<? extends T> kindClass, long id)

我可以得出这样的结论:为没有任何父关系的实体自动生成的 ID 是唯一的吗?

Auto-generated ID 对于一个种类是唯一的并且 parent。对于任何给定的种类和空值(不存在)parent,分配器将分配一个唯一值。

Each entity in Datastore has a key that uniquely identifies it. The key consists of the following components:

  • The namespace of the entity, which allows for multitenancy
  • The kind of the entity, which categorizes it for the purpose of Datastore queries
  • An identifier for the individual entity, which can be either a key name string an integer numeric ID
  • An optional ancestor path locating the entity within Datastore hierarchy

这些组件的联合使密钥唯一。 因此,自动生成策略 保证 ID 在同一 namespace|parent|kind|id 或仅 kind|id 如果没有 parent

来源:https://cloud.google.com/appengine/docs/java/datastore/entities