Use an ancestor-is query. This will find all entities which have a given ancestor as parent. It even works in a kind-less query, returning different kinds of entities under that parent. It's also quite efficient (especially from a pricing/CPU cost perspective) since theoretically, all this can be done on a single database node.
I'm not sure how to do ancestor-is query with JDO (I use my own type- safe wrapper over low-level API), but you could try something like: select from ... where ANCESTOR=... (like __key__, ANCESTOR seems to be a reserved name in app engine) On Mar 18, 7:56 am, tempy <[email protected]> wrote: > That's a good point, but in this case the resulting entity group > arrangement is intentional. Lock-in isn't a worry, I can confidently > say that these entity-group arrangements will last as long as the > application does. > > Though, as you point out, I can make a "parentKey" field on the child, > but since this parent key will also have to appear within the child's > key, having such a field is redundant and I would rather avoid it. > > On Mar 18, 3:51 pm, Tristan <[email protected]> wrote: > > > > > Something you may want to consider is that you are placing yourself > > within the limitations of entity groups by sticking children under > > parent keys. You may want to consider a model where the parent key is > > simply a field in the child and then run a simple query testing that > > the "parentKey" field is equal to the one you're looking for. This > > makes queries easier and prevents entity group lock-in. > > > Cheers! > > > On Mar 18, 8:55 am, tempy <[email protected]> wrote: > > > > I want to retrieve all entities that are children of one other > > > particular entity, by checking if the parent-key property of the > > > child's key matches the parent key. I have a reference to the parent > > > entity but I want to avoid loading all of its children (as there may > > > be many children, but I only need a few). Thus I want a query that > > > looks something like this: > > > > query = pm.newQuery("select from " + ChildClass.class.getName() + > > > " where :parentID.contains(ChildIDProperty.ParentID) && > > > SomeOtherProperty > " + filterString); > > > > But I'm not sure how to exactly address the parent key property of a > > > key in a query. > > > > Thanks, > > > Mike -- 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.
