[英]Is this the correct way to set and get a string value using persistance in GAE?
Is this the correct way to set and get a string value using persistance in GAE ? 这是在GAE中使用持久性设置和获取字符串值的正确方法吗?
I'm receiving error : 我收到错误消息:
com.google.appengine.api.datastore.EntityNotFoundException: No entity was found matching the key: jsonString("jsonString")
Adding to store : 新增至商店:
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key key = KeyFactory.createKey("jsonString", "jsonString");
Entity urlEntity = new Entity("jsonString" , key);
urlEntity.setProperty("urlVal", urlVal);
com.google.appengine.api.datastore.Key urlEntityKey = datastore.put(urlEntity);
Returning from store : 从商店退货:
Key key = KeyFactory.createKey("jsonString", "jsonString");
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity entity = datastore.get(key);
Please review the below code, also you can find more details on how to use the app engine datastore API by reviewing the documentation here . 请查看以下代码,通过查看此处的文档,您还可以找到有关如何使用App Engine数据存储区API的更多详细信息。 Also review the notes in the Datastore Overview document.
另外,请查看“ 数据存储区概述”文档中的注释。
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity e = new Entity("data");
e.setProperty("jsonString", "myValue");
Key key = ds.put(e);
Entity entity = ds.get(key);
System .out.println(entity);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.