简体   繁体   中英

Google App Engine - Deleted Entity is not deleted

I'm trying to delete an entity in google datastore

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.

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). If this snippet is a copy paste from your original then that's the mistake.

确保您没有活动的事务,如果您确实提交了事务。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM