Hi, I have a User class in my project, and I can't find a transactionally safe method of creating relationships between users, because User objects are always in their own entity group.
The simplest example I can come up with is a follow relationship (like twitter). When a user follows another, both User objects should be made aware of the relationship: class User { int mNumFollowing; int mNumFollowers; } class Follow { String mUsernameFollowed; String mUsernameFollower; } Since both User objects involved are root entities, I can't use a transaction to safely build the relationship. Ideally: tx.begin(); Follow follow = new Follow( userJoe.getUsername(), userJane.getUsername()); pm.makePersistent(follow); userJoe.mNumFollowing++; pm.makePersistent(userJoe); userJane.mNumFollowers++; pm.makePersistent(userJane); tx.commit(); I can make the Follow class an entity child of User, still the relationship can't be done in a single transaction: tx.begin(); userJoe.mNumFollowing++; pm.makePersistent(followForJoe); pm.makePersistent(userJoe); tx.commit(); tx.begin(); userJane.mNumFollowing++; pm.makePersistent(followForJane); pm.makePersistent(userJane); tx.commit(); the first transaction could succeed, and the second fail, leaving me with a half-completed follow relationship. What's the best way around same-entity-group-for-transactions in a situation like this? Do we just have to deal with the fact that our data might be incorrect? I could make User objects all children of a single entity group, but that would probably be awful for performance as every User object in the datastore would have to be locked to do a transaction (just guessing, I don't know if that's true). Thanks -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.