Transactions and ancestor in a different namespace

40 views
Skip to first unread message

Hugo Visser

unread,
Jul 22, 2011, 6:48:57 AM7/22/11
to Google App Engine
Is it anywhere explicitly documented that the ancestor of an entity
must have it's key in the same namespace as the entity itself? I'm
using namespaces a lot in our app and in production I get an error if
I try to do a transactional update of an entity with parent x in a
different namespace than the entity that I'm updating.

Is this intentional? If it is, I guess the dev server should also
check this, my unit tests pass :)

Hugo

Hugo Visser

unread,
Jul 23, 2011, 8:51:09 AM7/23/11
to Google App Engine
Well it appears that the entire key path for an entity group is bound
to one namespace. I am using Objectify in my app which doesn't have
the namespace in the keys but when checking out the low level Java api
that became apparent.

Jeff Schnitzer

unread,
Jul 23, 2011, 3:39:58 PM7/23/11
to google-a...@googlegroups.com
If you are using Objectify 3.0, the Key<?> is a simple wrapper for the native datastore Key - with all the same namespace consequences.  In previous versions, the Key<?> -> Key conversion was done last-minute so it would "inherit" the namespace then.

Jeff

--
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-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.


Hugo Visser

unread,
Jul 24, 2011, 3:50:56 PM7/24/11
to Google App Engine
Correct, I'm still on 2.2.3 (it's great, thanks!). Would I run into
big problems switching to 3.0 because of this? In only one or two
instances I ran into the last minute key conversion issue, but I've
worked around that with a ObjectifyWrapper which is actually not bad
at all. In the spirit of "if it ain't broke..." I haven't switched yet
to 3.0.

The thing is that we have data in a "main" namespace with historical
data in different namespaces. Previously this was all in one namespace
and because I want to update that data in a transaction it was in the
same entity group.
Now that it is crossing namespaces it looks like that can't be done
anymore, which is a bit of a pain but not a huge problem for now.

Hugo

Jeff Schnitzer

unread,
Jul 24, 2011, 4:06:14 PM7/24/11
to google-a...@googlegroups.com
I can't really tell whether the Key<?> change would be an issue for you - it would depend a lot on how you are using namespaces and how you generate keys (remote java client?  gwt?  server-side only?).  If you're using the "standard" practice of setting namespace *immediately* in a servlet Filter, you shouldn't notice any difference... but if you are manipulating namespaces in a more complicated way, it's hard to predict.  Namespace is a transient field in the native datastore Key, so it behaves... strangely.

Jeff

Hugo Visser

unread,
Jul 24, 2011, 4:12:41 PM7/24/11
to google-a...@googlegroups.com
Thanks Jeff, I'll just try the switch at a later time and see how it
goes. I'm pretty much managing the namespaces already in the code so I
think that shouldn't change much, and it's all server side.

Hugo

Reply all
Reply to author
Forward
0 new messages