Here is the code I use to delete one kind at a time - it batches the
keys into Lists of 100 to avoid datastore exceptions. Iterables is
from Google collections.
Query query = new Query(kind);
query.setKeysOnly();
DatastoreService datastore = ...
Iterable<Entity> entityIterator =
datastore.prepare(query).asIterable();
Iterable<Key> keyIterator = Iterables.transform(entityIterator,
new Function<Entity, Key>()
{
public Key apply(Entity arg0)
{
return arg0.getKey();
}
});
Iterable<List<Key>> partitioned =
Iterables.partition(keyIterator, 100);
for (List<Key> sublist : partitioned)
{
datastore.delete(sublist);
}
On 22 Jan 2010, at 15:10, mete wrote:
Suppose I have a class A and I have stored some instance of it in the
datastore. Then I change it, but I keep the name. How I can delete all
the previous data in the datastore, if I simply do a query and use
deleteAll, it gives an error (I guess because I changed the name of
some fields). Thank you.
Mete
--
You received this message because you are subscribed to the Google
Groups "Google App Engine for Java" group.
To post to this group, send email to [email protected]
.
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en
.
--
You received this message because you are subscribed to the Google Groups "Google
App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.