Can't wrap my head around appengine data store persistence
Posted
by aloo
on Stack Overflow
See other posts from Stack Overflow
or by aloo
Published on 2010-06-07T07:18:04Z
Indexed on
2010/06/07
7:22 UTC
Read the original article
Hit count: 322
Hi,
I've run into the "can't operate on multiple entity groups in a single transaction." problem when using APPENGINE FOR JAVA w/ JDO with the following code:
PersistenceManager pm = PMF.get().getPersistenceManager();
Query q = pm.newQuery("SELECT this FROM " + TypeA.class.getName()
+ " WHERE userId == userIdParam ");
q.declareParameters("String userIdParam");
List<TypeA> poos = (List<TypeA>) q.execute(userIdParam);
for (TypeA a : allTypeAs) {
a.setSomeField(someValue);
}
pm.close();
}
The problem it seems is that I can't operate on a multiple entities at the same time b/c they arent in the same entity group while in a transaction. Even though it doesn't seem like I'm in a transaction, appengine generates one because I have the following set in my jdoconfig.xml:
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
Fine. So far I think I understand.
BUT - if I replace TypeA in the above code, with TypeB - I don't get the error. I don't believe there is anything different between type a and type b - they both have the same key structure. They do have different fields but that shouldn't matter, right?
My question is - what could possible be different between TypeA and TypeB that they give this different behavior? And consequently what do you I fundamentally misunderstand that this behavior could even exist....
Thanks.
© Stack Overflow or respective owner