views:

470

answers:

1

I'm trying to delete some unwanted data from my datastore with Java and found some code using the DatastoreService that I modified to delete as many entries as possible in 10 seconds:

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query query = new Query("PostalCodes");
long starttime = (new Date()).getTime();
for (Entity entity : datastore.prepare(query).asIterable()) {
        datastore.delete(entity.getKey());
        if ((new Date().getTime()) > (starttime + 10000))
                break;
}

It seems to work when I run this. I check the console's data viewer and the Kind I'm trying to delete ("PostalCodes") is gone, but the day after I do this, the whole thing has been restored. Am I missing a call to flush or commit or something?!?

Is there a better way to do this?

A: 

Take a look at a similar question: http://stackoverflow.com/questions/108822/delete-all-data-for-a-kind-in-google-app-engine for other ways to bulk delete information.

Dave
Thanks for the link. I kept at it and eventually deleted the content I wanted, but I'm still not sure what was going on.
Eric Landry