I am seeing some transaction-related behaviour, using JDO and GAE
1.3.1, that puzzles me.
I get an exception if I do something like the following. All entities
below are in separate entity groups:
PersistenceManager pm = PMF.get().getPersistenceManager();
//... fetch entity a1 of kind A, modify a1...
// create or update several instances of kind 'B' (none share an
entity group)
for (String i: coll) {
Transaction tx = pm.currentTransaction();
tx.begin();
//... create or update instance i of kind B, make persistent
tx.commit();
}
// ...
pm.close();
Each transaction only includes work on a single entity (of kind B).
However, the transactions throw the "can't operate on multiple entity
groups in a single transaction" exception with respect to kinds A and
B. Note that entity a1 was NOT actually part of any transactional
activity but *was* accessed first as part of the PersistenceManager
session.
When I use a second different PersistenceManager session for the
series of transactions (and make no other code mods), all is well.
e.g.:
PersistenceManager pm = PMF.get().getPersistenceManager();
//... fetch entity A1 of kind A, modify A1...
PersistenceManager pm2 = PMF.get().getPersistenceManager();
// create or update several instances of kind 'B' (none share an
entity group)
for (String i: coll) {
Transaction tx = pm2.currentTransaction();
tx.begin();
//... create or update instance i of kind B, make persistent
tx.commit();
}
pm2.close();
// ...
pm.close();
Here, each of the different instances of kind B are in their own
individual entity group, but the series of transactions can share a
PersistenceManager session without error.
But, sharing a PersistenceManager session with the entity of kind A
was problematic. Is it that one can't 'mix' transactions and non-
transactional operations in the same PersistenceManager session?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.