Uhm .. Well my idea is to add always a new child at the end of the
list in order to don't update all the other "children_INTEGER_IDX"
property. That's why I defined a DESC index and when I try to add a
new child I use:
parent.getChildren().add(new Child(...));

.. assuming it just add a new child at the end of the list; but
probably here is the key point: which query does the "getChildren"
method launch?
Here is my simple implementation:
public List<Child> getChildren() {
return children;
}
.. so it touches the children property and try to add a new one. I
don't use JDO query, but simple java class methods.

What do you think?
Thank you
Michele

On Feb 3, 9:35 am, Matthew Jaggard <matt...@jaggard.org.uk> wrote:
> Do you ever have criteria to your query? If so, I think you need both
> indexes because below is the way that I think of queries working. I'm not
> sure if it's true - maybe a Googler could let us know if this is about
> right or wildly wrong?
>
> Use ascending index to find the first entity with the value required.
> Use descending index to find the last entity with the value required.
> Return all entity keys between the first and the last.
> If not a keys-only query - fetch the entities using a batch get.
>
> If this is the way it works, I wouldn't be surprised if Google have set it
> up to require both indexes because they would be required in all uses
> (because it would probably be just as quick to do sorting in memory if you
> fetch all entities).
>
> Thanks,
> Mat.
>
> On 3 February 2012 02:04, Bruno Fuster <brunofus...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I'm not sure but maybe JDO is trying to query asceding to fetch the
> > children before adding.
>
> > On Thu, Feb 2, 2012 at 9:36 PM, Miguel <doctormig...@gmail.com> wrote:
>
> >> Hi,
> >> I am working on a simple structure similar to:
>
> >> class Parent {
> >> ...
> >> List<Child> children
> >> ..
> >> }
>
> >> class Child {
> >> ..
> >> Parent parent
> >> ..
> >> }
>
> >> mapped with a 1-N relation in JDO:
> >> <field persistence-modifier="persistent" name="children" mapped-
> >> by="parent">
> >>        <collection dependent-element="true" element-type="Child"></
> >> collection>
> >>        <order/>
> >> </field>
>
> >> with a simple index:
> >> <datastore-index kind="Child" ancestor="true" source="manual">
> >>        <property name="children_INTEGER_IDX" direction="desc"/>
> >> </datastore-index>
>
> >> .. and I always retrieve Children in descending order.
>
> >> But when I add a children I get this error:
> >> com.google.appengine.api.datastore.DatastoreNeedIndexException: no
> >> matching index found.
> >> The suggested index for this query is:
> >>    <datastore-index kind="Child" ancestor="true" source="manual">
> >>        <property name="children_INTEGER_IDX" direction="asc"/>
> >>    </datastore-index>
>
> >> So my question is: why do I always need both indexes for ascending and
> >> descending order if I need only type of ordering?
>
> >> Thanks,
> >> Michele
>
> >> --
> >> 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
> >> google-appengine-java@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-appengine-java+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-appengine-java?hl=en.
>
> > --
> > Bruno Fuster
>
> >  --
> > 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
> > google-appengine-java@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com.
> > 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 google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to