开发者

Why do reads in google app engine datastore transactions not see previous writes or deletes?

ObjectifyBookShelfDAO transactionalDao = new ObjectifyBookShelfDAO(true);

for(Item item : items) {

transactionalDao.removeThisItem(item);

Item item =transactionalDao.againCheckThisItem(item); // why do get back this item even //after removing?

if(item != null)

{开发者_C百科

// do some operation

transactionalDao.savethisItem(item);

}

transactionalDao.ofy().getTxn().commit();

Now the problem here is on removing some item when i check for the same item i get that item which means that even after removing it still exists in Database . . How do i solve this problem?


it's counterintuitive, but this is actually the expected behavior. from the datastore transaction docs:

Queries and gets inside a transaction are guaranteed to see a single, consistent snapshot of the datastore as of the beginning of the transaction...This consistent snapshot view also extends to reads after writes inside transactions. Unlike with most databases, queries and gets inside a datastore transaction do not see the results of previous writes inside that transaction. Specifically, if an entity is modified or deleted within a transaction, a query or get returns the original version of the entity as of the beginning of the transaction, or nothing if the entity did not exist then.

see the datastore transaction isolation article for more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜