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

标签 java google-app-engine objectify

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

@id
Long ID;

我将 null 放入变量 ID,因此 App Engine 会自动为我的实体生成 ID。

通过对象化函数创建 key :

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

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

最佳答案

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

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

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

关于java - App Engine 是否自动生成 Long @id 在实体范围内是唯一的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29483724/

相关文章:

java - 当我们使用 PHP 进行开发时,平台的名称是什么?

google-app-engine - GAE - 无法将 JSP 文件添加到项目中

node.js - 无法选择区域和/或区域。部署 NodeJS 托管虚拟机应用程序时

java - 嵌入式数组内的对象化嵌入式数组无法持久存在

java - 为服务媒体项目(照片、mp3、文档等)生成 key 的最佳实践

java - Objectify - 查询结果列表包含 null

java - 我程序上的额外 + 标志

java - 自定义布局未在 mainActivity 类中检测到?

java - 方法重载不适用于不同的参数

android - 在 Google AppEngine 上运行部署的应用程序时出现问题