After more test it seems that I can retrieve ancestor's childs for a
Kind but without Kind the query won't work.
> I have a class *GAEDaoSupport* who convert *Object* to *Entity* while
> copying properties. I have a JUnit test for this class who check the
> conversion and try to store and retrieve values.
> When I try to store a *List* of *Entity* where the first is the ancestor and
> others are childs I can retrieve all of them by *Key *but a kindless *Query* on
> ancestor *Key* return nothing.. I suppose that I'va missed something but
> don't now what..
>
> Here is my test case and the output...
>
> > GAEDaoSupport support = *new *GAEDaoSupport(RoleEntity.*class*);
> > RoleEntity object = newRelationsEntity();
>
> > DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
> > List<Entity> entities = support.createEntity(object);
> > System.out.println(" -- [1] Storing "+entities.size()+" entities -------"
> > );
> > System.out.println(entities);
> > List<Key> keys = ds.put(entities);
> > System.out.println("\t \\-> Done. Keys : "+keys);
>
> > *try *{
> > // Pass...
> > Entity stored = ds.get(entities.get(0).getKey());
> > assertEquals(entities.get(0), stored);
>
> // Pass...
>
>
>
>
>
>
>
>
>
> > *for *(*final *Entity child : entities.subList(1, entities.size())) {
> > assertEquals(child, ds.get(child.getKey()));
> > }
>
> > // Fail !!! , Result is empty
> > System.out.println();
> > System.out.println(" -- [2] Retrieving entities by ancestor
> > ------------");
> > Query query = new Query()
> > .setAncestor(entities.get(0).getKey());
> > System.out.println("\t - Query : "+query);
>
> > List<Entity> childs =
> > ds.prepare(query).asList(FetchOptions.Builder.withDefaults());
> > System.out.println("\t \\-> Done : "+childs);
> > } *catch *(EntityNotFoundException e) {
> My test case use a simple *LocalServiceTestHelper *, like described into the
> gae documentation :
>
>
>
>
>
>
>
> > *private final* LocalServiceTestHelper helper =
> > *new *LocalServiceTestHelper(*new *
> > LocalDatastoreServiceTestConfig());