What steps will reproduce the problem?
This detached entity won't save to the datastore after merge. I've tried dozens
of tricks with no luck. Is the solution JDO or raw Datastore API? It just won't
save, no matter how long I wait.
EntityManager em = EMF.get().createEntityManager();
em.getTransaction().begin();
OnixUser s = admin.get(0);
if (s.id == null) {
em.persist(s);
em.getTransaction().commit();
}
else {
log.info("email:" + s.email + ", isAdmin:" + s.isAdmin + ", id:" + s.id + ", state:" + NucleusJPAHelper.getObjectState(s));
OnixUser merged = em.merge(s);
log.info("merged... email:" + merged.email + ", isAdmin:" + merged.isAdmin + ", id:" + merged.id + ", state:" + NucleusJPAHelper.getObjectState(merged));
em.persist(merged); //// TRIED WITH & WITHOUT PERSIST
log.info("persisted... email:" + merged.email + ", isAdmin:" + merged.isAdmin + ", id:" + merged.id + ", state:" + NucleusJPAHelper.getObjectState(merged));
em.flush();
log.info("flushed... email:" + merged.email + ", isAdmin:" + merged.isAdmin + ", id:" + merged.id + ", state:" + NucleusJPAHelper.getObjectState(merged));
em.getTransaction().commit();
em.refresh(merged);
/////// THIS IS WHERE IT FAILS isAdmin reverts back to 0.
log.info("refreshed... email:" + merged.email + ", isAdmin:" + merged.isAdmin + ", id:" + merged.id + ", state:" + NucleusJPAHelper.getObjectState(merged));
}
em.close();
###Log
Oct 16, 2013 10:25:10 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: email:chloe@example.com, isAdmin:1, id:4793870697103360, state:detached
Oct 16, 2013 10:25:10 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: merged... email:chloe@example.com, isAdmin:1, id:4793870697103360, state:persistent
Oct 16, 2013 10:25:10 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: persisted... email:chloe@example.com, isAdmin:1, id:4793870697103360, state:persistent
Oct 16, 2013 10:25:10 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: flushed... email:chloe@example.com, isAdmin:1, id:4793870697103360, state:persistent
Oct 16, 2013 10:25:10 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: refreshed... email:chloe@example.com, isAdmin:0, id:4793870697103360, state:persistent
###Finest Log
Oct 17, 2013 12:36:34 PM com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection <init>
FINE: Created ManagedConnection using DatastoreService = com.google.appengine.api.datastore.DatastoreServiceImpl@470d08b4
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection added to the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@58de89bb for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@61478c16]
Oct 17, 2013 12:36:34 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: email:chloe@example.com, isAdmin:1, id:6394759627145216, state:detached
Oct 17, 2013 12:36:34 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.example.sdm.shared.OnixUser@636a0148" (id="com.example.sdm.shared.OnixUser:6394759627145216") has a lifecycle change : "P_CLEAN"->"P_NONTRANS"
Oct 17, 2013 12:36:34 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: merged... email:chloe@example.com, isAdmin:1, id:6394759627145216, state:persistent
Oct 17, 2013 12:36:34 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: persisted... email:chloe@example.com, isAdmin:1, id:6394759627145216, state:persistent
Oct 17, 2013 12:36:34 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: flushed... email:chloe@example.com, isAdmin:1, id:6394759627145216, state:persistent
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl$1 managedConnectionPostClose
FINE: Connection removed from the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@58de89bb for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:tx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@61478c16]
Oct 17, 2013 12:36:34 PM com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection <init>
FINE: Created ManagedConnection using DatastoreService = com.google.appengine.api.datastore.DatastoreServiceImpl@1c00f18e
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection added to the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@1f2afff for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@4949a70e]
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl allocateConnection
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@1f2afff for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@4949a70e]
Oct 17, 2013 12:36:34 PM com.example.sdm.server.SDMServiceImpl setAdmin
INFO: refreshed... email:chloe@example.com, isAdmin:0, id:6394759627145216, state:persistent
Oct 17, 2013 12:36:34 PM org.datanucleus.state.LifeCycleState changeState
FINE: Object "com.example.sdm.shared.OnixUser@636a0148" (id="com.example.sdm.shared.OnixUser:6394759627145216") has a lifecycle change : "P_NONTRANS"->"DETACHED_CLEAN"
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl closeAllConnections
FINE: Connection found in the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@1f2afff for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@4949a70e] but owner object closing so closing connection
Oct 17, 2013 12:36:34 PM org.datanucleus.store.connection.ConnectionManagerImpl$1 managedConnectionPostClose
FINE: Connection removed from the pool : com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl$DatastoreManagedConnection@1f2afff for key=org.datanucleus.ObjectManagerImpl@3e3ad48 in factory=ConnectionFactory:nontx[com.google.appengine.datanucleus.DatastoreConnectionFactoryImpl@4949a70e]
Oct 17, 2013 12:36:34 PM com.google.apphosting.utils.jetty.AppEngineAuthentication$AppEngineUserRealm disassociate
FINE: Ignoring disassociate call for: chloe@example.com
###Versions
datanucleus-api-jpa-3.1.3.jar, appengine-api-1.0-sdk-1.8.5.jar, Windows 8
What is the expected output? What do you see instead?
Expected to see isAdmin changed to 1 in the AppEngine admin interface for the
entity. Expect to see isAdmin = 1 after em.refresh().
http://stackoverflow.com/questions/19417398/bug-in-gae-datanucleus-wont-save-to-
google-appengine-datastore-with-jpa-2
Original issue reported on code.google.com by starrych...@oliveyou.net on 17 Oct 2013 at 4:53
Original issue reported on code.google.com by
starrych...@oliveyou.net
on 17 Oct 2013 at 4:53