Entity groups are distributed based on the key and not necessarily the root
entity. Thus, it is possible to place entities in the same entity group
without an entity parent. Something similar to what you have done is also
possible by creating a root entity, adding descendants, then removing the
root entity. Transactions are possible for entities in the same entity
group.

On Sun, Dec 6, 2009 at 8:15 PM, Yasuo Higa <[email protected]> wrote:

> Hi all,
>
> As the following document(54p) says,
> journal and last committed timestamp are co-located with a root entity
> of an entity group.
> http://snarfed.org/space/datastore_talk.html
>
> But, an entity group that does not have a root entity seem to support
> transaction.
> How does it work?
>
> I tried the following code on production server:
>
> DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
> Key parentKey = KeyFactory.createKey("Parent", 1);
> Key child1Key = KeyFactory.createKey(parentKey, "Child", 1);
> Key child2Key = KeyFactory.createKey(parentKey, "Child", 2);
>
> Transaction tx1 = ds.beginTransaction();
> ds.put(tx1, new Entity(child1Key));
>
> Transaction tx2 = ds.beginTransaction();
> ds.put(tx2, new Entity(child2Key));
>
> tx1.commit();
> try {
>    tx2.commit();
> } catch (ConcurrentModificationException e) {
>    System.out.println(
>        "An entity group that does not have a root entity supports
> transaction.");
> }
> try {
>    ds.get(parentKey);
> } catch (EntityNotFoundException e) {
>    System.out.println("There is no root entity.");
> }
> ds.delete(child1Key);
>
> App Engine SDK version:1.2.8
>
> Thanks,
>
> Yasuo Higa
>
> --
>
> 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.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

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.


Reply via email to