0

I am running into an issue where the datastore table does not immediately update when an entity is deleted, and can be accessed with DB.find.

Here is the flow:

1. DB.find(key) --> object
2. DB.delete(object)
3. DB.find(key) --> object (not null) 

I expect DB.find(key) to return null because the object was not deleted but that is not the case. However, after all logic completes and response has been returned I see that the entity has been successfully deleted.

Why is the entity still able to be found within the same function?

Also, each of the DB access steps are wrapped with ObjectifyService transaction, for example:

Boolean txnRes = ObjectifyService.ofy().transact(new Boolean() {
            @Override
            public Boolean run() {
               object = DB.find(key)
               return object != null
            }
        });
treesan
  • 49
  • 2

1 Answers1

1

As per the answer by @Dan Cornilescu on this thread. you have to call .delete() on the entity's key, instead of entity itself. I.e

DB.key.delete()

Also check this document

Roopa M
  • 2,171
  • 4
  • 12