在Google App Engine(Java)中保存预持久对象的问题 [英] Problems while saving a pre-persisted object in Google App Engine (Java)

查看:83
本文介绍了在Google App Engine(Java)中保存预持久对象的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在google-app-engine数据存储中保存预持久化的JDO对象时,我遇到问题。基本上,在一个servlet中,我创建对象并保存它。在另一个servlet中,我读取对象,设置一堆属性并尝试更新它。更新是通过 PersistenceManager 上的 makePersistent 调用。抛出异常并且没有警告日志。但是,当我稍后访问同一个对象时,它仍然处于原始状态。

I am having problems while saving a pre-persisted JDO object in google-app-engine data store. Basically, in one servlet, I create the object and save it. In another servlet, I read the object, set a bunch of properties and try updating it. The update is through a makePersistent call on PersistenceManager. There is no exception being thrown and no warning logs. However, when I access the same object later, its still in its original state.

PersistenceManager 在读取和更新之间从未关闭(如数据存储文档

The PersistenceManager is never closed between the read and the update (as suggested in the Datastore documentation)

唯一可能的与文档中的示例不同的是,读取是用于列表,但更新是为独立对象完成的。文档中没有什么不鼓励这个。这可能是一个问题?

The only thing that might be different than the example in the documentation is that the reads are for lists, but the updates are done for the independent object. There is nothing in the documentation that discourages this. Could that be a problem?

为了完成上下文,我只在Eclipse中尝试这个,还没有在AppEngine中实际尝试过。关于可能发生的事情的任何建议?

To complete the context, I am trying this only in Eclipse and haven't yet actually tried it in the AppEngine. Any suggestions on what might be happening?

推荐答案

原来,问题是 PersistenceManager 需要在 makePersistent 调用后关闭。我试过一样,现在工作。当然,在下次调用JDO之前,您需要重新打开 PersistenceManager 。它以任何一种方式工作 - 无论是保存列表,还是保存独立对象,通过检索可能已在列表中。

Turns out the the problem is that the PersistenceManager needs to be closed after the makePersistent call. I tried the same and it now works. Of course, you need to reopen the PersistenceManager before you make your next call to the JDO. It works either way - whether you save the list as it is, or save the independent objects, through the retrieve might have been in the list form.

这篇关于在Google App Engine(Java)中保存预持久对象的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆