Problems while saving a pre-persisted object in Google App Engine (Java)

别等时光非礼了梦想. 提交于 2019-12-07 17:35:15

问题


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.

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?

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?


回答1:


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.



来源:https://stackoverflow.com/questions/1372174/problems-while-saving-a-pre-persisted-object-in-google-app-engine-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!