gpt4 book ai didi

java - 为什么谷歌应用引擎数据存储事务中的读取看不到以前的写入或删除?

转载 作者:行者123 更新时间:2023-12-04 06:38:55 27 4
gpt4 key购买 nike

ObjectifyBookShelfDAO transactionalDao = new ObjectifyBookShelfDAO(true);
for(项目项目:项目){
transactionalDao.removeThisItem(item);
Item item =transactionalDao.againCheckThisItem(item);//为什么即使在移除之后还要取回这个项目?
如果(项目!= null)
{
//做一些操作
transactionalDao.savethisItem(item);
}

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

现在这里的问题是当我检查同一个项目时删除一些项目我得到了那个项目,这意味着即使在删除它之后它仍然存在于 Database 中。 .我该如何解决这个问题?

最佳答案

这是违反直觉的,但这实际上是预期的行为。来自 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.



datastore transaction isolation article更多。

关于java - 为什么谷歌应用引擎数据存储事务中的读取看不到以前的写入或删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4516124/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com