First off I know that you can't operate on entities in different entity groups within the same transaction. My question is around a problem I am having where I am querying for certain entities (each in a different entity group) outside a txn and then I start a txn where I operate on an entity in a different entity group.
In my model I have a root entity called User. So each instance of User will be in a different entity group. Here is what I am doing in pseudo-code: *Request comes in Create EntityManager Execute a JPA query using this EntityManager to retrieve the keys for all User entities satisfying a particular criteria (say we got UserKey1, UserKey2, UserKey3 back) Using EntityManager Start a txn Retrieve User with id : UserKey4 (notice this is different from the ones we retrieved above) Update this User object. Commit txn <<<<<<<<<<<<<<<<<<<<<<< Intermittently fails here Close EntityManager Return response * Notice here that the initial query is not part of the transaction that is subsequently created.* Inside that transaction only a single entity group is operated upon* (the Entity group for User object UserKey4). The first time the request goes in (after a server start) this code intermittently fails. Every subsequent request fails pretty consistently. The exception occurs at the commit with the infamous: "can't operate on multiple entity groups" exception. The 2 entities listed in the exception are the following: 1. the UserKey4 2. One of the User objects whose keys were returned in the initial query. This is really weird since within the txn I am operating on a single entity group. If my understanding is correct I should be able to do this. The only rational reason why this is happening might be that even querying for objects outside a txn and any subsequent txn should deal with entities in the same entity group. Is that the case or am I missing something here ? I have not been able to find a definite answer to this in the documentation so thought I'd try the mailing list. Thanks Yousuf -- 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.
