How can I delete active object entities using the stream api?

When I try to delete AO entities that I’ve fetched using I get a error:

cannot be cast to

The code:

final List categoryCacheEntities = new ArrayList();, new EntityStreamCallback<CategoryCacheEntity, Integer>()
public void onRowRead(CategoryCacheEntity categoryCacheEntity)
for(CategoryCacheEntity e : categoryCacheEntities)

Using ao.find works just fine. Any ideas?

It looks like the entities returned as part of the stream was not intented to be used with ao.delete(). The entities returned in stream() implement a different (interface) type to the ones from the find() method (which does implement the EntityProxyAccessor internface).

I suggest you try using ao.deleteWithSQL() rather than ao.delete(). It will also take up less memory to use deleteWithSQL, since you do not have to keep in memory a list of the entities to be deleted.

Thanks, I’ll try the deleteWithSQL solution!