Intermittent Issue Writing to Google Appengine Datastore
- by user242153
Hi, I have a functioning app and recently have had intermittent
problems writing to the datastore. I did not make any relevant code
changes, however in the last few days my attempts to write to the
datastore sometimes work and sometimes don't.
I am trying to save an object that is in a many to one relationship
with an existing persisted parent. So, the logic works like this:
1) Parent pulled from the datastore
2) Child created / instantiated using constructor
3) Parent.addSingleChild(child); // the "addSingleChild" method
just adds the object argument to the collection of children
4) child.setParent(Parent); // sets the Parent object to the
parent field
I am using transactions as explained in the documentation ending with
"finally {if (tx.isActive()) {tx.rollback(); } }"
When the servlet is called, the parent is called from the datastore
and the child object is created and added to the many to one mapping
to the pre-existing parent.
The child should automatically be persisted, since the parent is
already persistent, and the child is added to the collection of
children that map to the parent. And it worked this way in the
past. However, to be sure, i did add a pm.makePersistent(child).
Doesn't seem to help, still have the intermittent problem.
Any suggestions would be appreciated, and if you need to see the
actual code I can post. Thanks