Ugorji, This sounds good but I haven't found a way to accomplish it in JDO. The closest is, I think, is described here:
http://code.google.com/appengine/docs/java/datastore/transactions.html#Using_Transactions "To create an object with a system-generated numeric ID and an entity group parent, you must use an entity group parent key field (such as customerKey, above). Assign the key of the parent to the parent key field, then leave the object's key field set to null. When the object is saved, the datastore populates the key field with the complete key, including the entity group parent." Which doesn't work for me because I have to explicitly create the key of the child. Tristan, I think your approach is the correct one. The single-entity-group write limit is something new to me, new and worrisome. =/ I need the entity groups that I have for transactionality and faster read speeds, but the write-limit is something I will have to deal with. Thanks for the advice! On Mar 18, 4:28 pm, Ugorji <[email protected]> wrote: > 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.
