无法在数据存储区视图中找到通过 objectify 持久化的实体
Can't find the entities persisted with objectify in the datastore view
我在 Google Cloud 上有一个非常简单的 hello world 应用程序,带有 objectify。
我正在使用最新的 Google Cloud Tools (1.6.1) for eclipse (Oxygen 4.7.3a)、Java 8 和 运行ning 数据存储模拟器(如)
中描述
我能够保存一些实体,我可以看出它们是持久的,因为我可以在重启模拟器后检索它们,我知道它们存储在:"C:\Users\XXXX\AppData\Roaming\gcloud\emulators\datastore\WEB-INF\appengine-generated"
但我无法在任何命名空间下的数据存储区视图中找到这些实体。知道我在这里错过了什么吗?
空数据存储视图:
代码:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
Car porsche = new Car("2FAST", 4);
ofy().save().entity(porsche).now(); // async without the now()
assert porsche.id != null; // id was autogenerated
Car fetched2 = ofy().load().type(Car.class).id(porsche.id).now();
Query cars = ofy().load().type(Car.class).chunkAll();
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().print("Hello App Engine!\r\n");
response.getWriter().print(fetched2.id + " " + fetched2.license);
response.getWriter().print("\ncars.count():" + cars.count() + "\n");
List carsList = cars.list();
for(Car c :carsList) {
response.getWriter().println(c.id + " " + c.license);
}
String namespace = NamespaceManager.get();
response.getWriter().println();
response.getWriter().println("namespace: ");
}
运行 模拟器:
运行配置:
本地管理数据存储页面由本地开发服务器提供,似乎只有当开发服务器本身在独立模式下执行数据存储模拟时,它才会显示有效信息。那是没有连接到数据存储模拟器,如果您没有设置连接到模拟器所需的环境,就会发生这种情况。在数据存储模拟器出现之前,这曾经是唯一的操作模式。
我在使用数据存储模拟器时没有找到访问 equivalent/similar 信息的方法,Running the Cloud Datastore Emulator 中没有提到这种功能。只有数据存储模拟器才能可靠地提供此类信息,因为它可以同时服务于多个开发 servers/apps(忘记彼此的存在)。
如果您不需要 运行 多个开发服务器共享同一个数据存储( 的反向),那么您可以简单地不设置 DATASTORE_EMULATOR_HOST
环境变量在启动开发服务器并且不将 --support_datastore_emulator=true
传递给它之前 - 然后开发服务器将使用它自己的数据存储模拟,您应该在其管理页面中看到信息。
请注意,数据存储模拟器可能使用了与开发服务器不同的数据内部格式,如果您返回可能会导致问题,您可能需要清理 C:\Users\XXXX\AppData\Roaming\gcloud\emulators\datastore
存储目录,恢复以前的格式或使用备用目录。来自 Migrating to the Cloud Datastore Emulator:
Currently, the local Datastore emulator stores data in sqlite3 while
the Cloud Datastore Emulator stores data as Java objects.
When dev_appserver is launched with legacy sqlite3 data, the data will
be converted to Java objects. The original data is backed up with the
filename {original-data-filename}.sqlitestub.
我在 Google Cloud 上有一个非常简单的 hello world 应用程序,带有 objectify。
我正在使用最新的 Google Cloud Tools (1.6.1) for eclipse (Oxygen 4.7.3a)、Java 8 和 运行ning 数据存储模拟器(如
我能够保存一些实体,我可以看出它们是持久的,因为我可以在重启模拟器后检索它们,我知道它们存储在:"C:\Users\XXXX\AppData\Roaming\gcloud\emulators\datastore\WEB-INF\appengine-generated"
但我无法在任何命名空间下的数据存储区视图中找到这些实体。知道我在这里错过了什么吗?
空数据存储视图:
代码:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
Car porsche = new Car("2FAST", 4);
ofy().save().entity(porsche).now(); // async without the now()
assert porsche.id != null; // id was autogenerated
Car fetched2 = ofy().load().type(Car.class).id(porsche.id).now();
Query cars = ofy().load().type(Car.class).chunkAll();
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
response.getWriter().print("Hello App Engine!\r\n");
response.getWriter().print(fetched2.id + " " + fetched2.license);
response.getWriter().print("\ncars.count():" + cars.count() + "\n");
List carsList = cars.list();
for(Car c :carsList) {
response.getWriter().println(c.id + " " + c.license);
}
String namespace = NamespaceManager.get();
response.getWriter().println();
response.getWriter().println("namespace: ");
}
运行 模拟器:
运行配置:
本地管理数据存储页面由本地开发服务器提供,似乎只有当开发服务器本身在独立模式下执行数据存储模拟时,它才会显示有效信息。那是没有连接到数据存储模拟器,如果您没有设置连接到模拟器所需的环境,就会发生这种情况。在数据存储模拟器出现之前,这曾经是唯一的操作模式。
我在使用数据存储模拟器时没有找到访问 equivalent/similar 信息的方法,Running the Cloud Datastore Emulator 中没有提到这种功能。只有数据存储模拟器才能可靠地提供此类信息,因为它可以同时服务于多个开发 servers/apps(忘记彼此的存在)。
如果您不需要 运行 多个开发服务器共享同一个数据存储(DATASTORE_EMULATOR_HOST
环境变量在启动开发服务器并且不将 --support_datastore_emulator=true
传递给它之前 - 然后开发服务器将使用它自己的数据存储模拟,您应该在其管理页面中看到信息。
请注意,数据存储模拟器可能使用了与开发服务器不同的数据内部格式,如果您返回可能会导致问题,您可能需要清理 C:\Users\XXXX\AppData\Roaming\gcloud\emulators\datastore
存储目录,恢复以前的格式或使用备用目录。来自 Migrating to the Cloud Datastore Emulator:
Currently, the local Datastore emulator stores data in sqlite3 while the Cloud Datastore Emulator stores data as Java objects.
When dev_appserver is launched with legacy sqlite3 data, the data will be converted to Java objects. The original data is backed up with the filename {original-data-filename}.sqlitestub.