We could perhaps be a bit more precise in our language here. You can run any query you want inside a transaction but the results are only guaranteed to be transactionally consistent if the query is an ancestor query. In other words, begin/commit are no-ops for non-ancestor queries.
Here's the history of it: We considered throwing an exception, but the problem was that when we first launched we didn't support transactional queries of any sort. We concluded that requiring developers to step around transactions any time they wanted to issue a query was a pretty heavy burden, so we decided to ignore active transactions for all queries. Then, once we figured out how ancestor queries could participate in a transaction, there was no way to go back because if we started throwing exceptions for non-ancestor queries in transactions existing apps would break when we pushed a new SDK to the back-ends. Hope that helps, Max On Thu, Mar 25, 2010 at 11:49 AM, AJ <[email protected]> wrote: > hi, > > The documentation on transactions says: > "An app can perform a query during a transaction, but only if it > includes an ancestor filter." > (<http://code.google.com/appengine/docs/java/datastore/ > transactions.html#What_Can_Be_Done_In_a_Transaction<http://code.google.com/appengine/docs/java/datastore/%0Atransactions.html#What_Can_Be_Done_In_a_Transaction> > >) > > This does not seem to be the case-- it seems that more general queries > are okay (as long as they don't return objects outside the entity > group). I noticed that some of the examples on Max's blog showed non- > ancestor-filter queries inside a transaction. > So, I gave it a try myself (the test query returned an object in the > same entity group as the other transaction operations) and it worked > fine. > > Soooo... what is the status of this restriction, of requiring an > ancestor filter? If it no longer holds, it would be useful to remove > the qualification from the docs. Or is the situation more complex? > > -- > 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]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > -- 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.
