我被坚持通过其编号创建持久对象。我得到一个错误:Google App Engine通过密钥获取对象
com.google.appengine.api.datastore.EntityNotFoundException: No entity was found matching the key: CNG("T78")
我坚持的对象,如下到数据存储:
Key cngKey = KeyFactory.createKey("CNG", jsonCNG.cNGID);
Entity cngEntity = new Entity("CNG", cngKey);
cngEntity.setProperty("cng_name", jsonCNG.cNGName);
cngEntity.setProperty("cng_type", jsonCNG.cNGType);
cngEntity.setProperty("cng_content", cng);
这里CNG是一个JSON字符串。我用一个字符串设置密钥:cNGID。我正在尝试使用相同的ID来获取对象。
Key cngKey = KeyFactory.createKey("CNG", "T78")
并最终得到上述错误。
其实,我把它保存到数据源。抱歉代码丢失。 –