user1157751
user1157751

Reputation: 2457

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.

Upvotes: 0

Views: 402

Answers (2)

user1258245
user1258245

Reputation: 3639

Make sure you don't have a transaction active and if you do commit it.

Upvotes: 1

Lipis
Lipis

Reputation: 21835

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.

Upvotes: 1

Related Questions