views:

160

answers:

1

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  A: 

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.

Shreeni
This was a nasty gotcha for me when picking up JDO. In my head I pictured a PM as similar to a JDBC connection, which is not really the case.
Peter Recore