Saturday, June 19, 2010

Appengine JDO Issue: JDOFatalUserException

I recently ran into a weird appengine JDO issue (as far as I understand). Here is the background.

I got the following exception:

javax.jdo.JDOFatalUserException: Illegal argument
NestedThrowables:
java.lang.IllegalArgumentException: can't operate on multiple entity groups in a single transaction. found both Element

It is expected to see this exception when you do any DB operations (fetch, save, delete, etc.) within the context of the same JDO transaction on 2 entities that are not in the same entity-group.

I do not get this exception when there is NO transaction active on the entire execution thread of the request. This is expected and working fine, if I read the specs correctly.

Now the weird part of this. If I have another transaction in progress (of course, on another PersistenceManager, but active in the same request), I get the above exception. Note that the PersistenceManager on which I get this error is not a part of any transaction. Is this a appengine JDO implementation bug? I don't know - for now, we will need to work around this issue.