As Max says, the datastore has native support for entity hierarchies, more commonly referred to as entity groups. Every entity is part of an entity group, but unless you specify a parent for a given entity before persisting it, it is stored as a root entity. Once you save an entity, you cannot change its entity group (i.e. parent).
Be sure to read up on entity groups before designing your data model. They are one of the more complex topics around App Engine, and even though they enable certain desirable mechanisms, such as transaction support, you should also be aware of undesirable side effects such as decreased write throughput. More information, including tips to follow, is available here: http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html#Entity_Groups_Ancestors_and_Paths - Jason On Thu, Oct 15, 2009 at 2:50 AM, emater <[email protected]> wrote: > > I avoid to dive in it, but after reading "child of the same class" > discussion > it seems to me that, in order to make less and smarter sql queries > behind, lov level api is the only good solution. > > Thanks for the point. > Emre. > > > On Oct 15, 3:30 am, Max Zhu <[email protected]> wrote: > > Datastore naturally supports hierarchy data structure. > > > > Low-level API is quite good to implement your logic > > > > On Wed, Oct 14, 2009 at 7:24 PM, emater <[email protected]> wrote: > > > > > Hi, > > > > > I have a User class... I couldn't achieve to set this relationship > > > below. > > > Any help would be appreciated. > > > > > User { > > > > > @PrimaryKey > > > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > > > Long id; > > > > > @Persistent > > > String xxx; > > > ..... > > > .... > > > ..... > > > @Persistent > > > User parent; <---- > > > > > } > > > > > parent is also a User type... I will try to set a hierarchy between > > > same objects in one table... > > > For example there is a Users table... > > > id column --> userid > > > parent_id column --> userid > > > > > sample data: > > > id=1,username=root,parent_id=0 > > > id=2,username=child1,parent_id=1 > > > id=3,username=child2,parent_id=1 > > > > > this is possible with hibernate with such setting: > > > <many-to-one name="parent" class="MClass" column="PARENT_ID"/> > > > > > but how with appengine? :) > > > > > Thanks for any help. > > > Emre. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
