gpt4 book ai didi

java - 谷歌应用引擎: How to "close" an object before second transaction?

转载 作者:行者123 更新时间:2023-12-01 16:03:14 25 4
gpt4 key购买 nike

这是我的方法之一的伪代码:

1. Get PersistenceManager (pm)


2. pm.fetchObject1

3. pm.beginTransaction

4. pm.modifyObject1

5. pm.commit


6. pm.fetchObject2

7. pm.beginTransaction

8. pm.modifyObject2

9. pm.commit

但是我收到此错误“无法对一个中的多个实体组进行操作”单笔交易...”

我是否需要在步骤 5 和步骤 7 之间再添加一行来表示我对象 1 已“完成”,想要关闭它吗?

谢谢

最佳答案

虽然你所说的应该有效,但它可能是 bug在应用程序引擎中。同时,您可以执行以下操作(伪代码),或者将实体 object1 和 object2 放在同一实体组中。有关交易和实体组的更多信息 here

  1. Get PersistenceManager (pm)

2. pm.currentTransaction (tx)

3. tx.begin

4. pm.fetchObject1

5. modifyObject1

6. tx.commit

7. pm.close


8. Get PersistenceManager (pm)

9. pm.currentTransaction (tx)

10. tx.begin

11. pm.fetchObject2

12. modifyObject2

13. tx.commit

14. pm.close

还有更多讨论here

关于java - 谷歌应用引擎: How to "close" an object before second transaction?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3282065/

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