I am using JDO (3.x, with datanucleus 2) to persist objects in one of my apps in the google app engine (java). My sequence of calls are such:
Open persistence manager in servlet filter (servlet 1) - Using ThreadLocal
call pm.findByObjectId from DAO class (via servlet 1)
call pm.deletePersistent from DAO class (via servlet 1)
call pm.newQuery to list all objects now in db (via servlet 1) - write to response (json)
Close persistence manager in servlet filter - inside finally of doFilter method
However, my objects are not being deleted until I close the pm in step 5. Also it is not consitent, sometimes it does get deleted !(havent figured out when). I would ideally want the objects to be deleted in Step 3 above, so that when in step 4 my query runs, it returns the updated list.
Could anyone please let me know if I could improve on this design to do inserts/deletes more atomically that this. Or is it just because the writes to the database are too slow ?
Here's my jdoconfig.xml
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
<property name="datanucleus.appengine.singletonPMFForName" value="true"/>
</persistence-manager-factory>