[英]Google App Engine - Deleted Entity is not deleted
I'm trying to delete an entity in google datastore 我正在尝试删除Google数据存储区中的实体
String keyValue = "someValue";
Key tweetKey = KeyFactory.createKey("tweetKey", keyValue);
Entity someEntity = new Entity(tweetKey);
Entity getEntity = datastore.get(tweetKey);
datastore.delete(tweetKey);
getEntity = datastore.get(tweetKey);
if(getEntity != null)
{
//This happens
System.out.println("Something wrong");
}
The entity are not deleted, and it something wrong as the output 实体不会被删除,输出也有问题
Edit 1: I didn't copy and paste from the original code, because there are a lot of other logic in between getting and using values from the entity. 编辑1:我没有从原始代码中复制和粘贴,因为在获取和使用实体的值之间存在很多其他逻辑。
You are deleting a different key than the one you are checking. 您正在删除与您正在检查的密钥不同的密钥。
You are deleting the tweetKey
and checking the tweetkey
(notice the capital K
in the first one). 您正在删除
tweetKey
并检查tweetkey
(注意第一个中的大写tweetkey
K
)。 If this snippet is a copy paste from your original then that's the mistake. 如果此片段是原始文件的复制粘贴,那么这就是错误。
确保您没有活动的事务,如果您确实提交了事务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.