google-code-export / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
1 stars 0 forks source link

Objectify#query() does'nt work as expected #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From the documentation of type Objectify:

/**
 * <p>Create a typesafe query across all kinds of entities.</p>
 */
<T> Query<T> query();

/**
 * <p>Create a typesafe query across one specific kind of entity.</p>
 */
<T> Query<T> query(Class<T> clazz);

A test case (version 2.2.1):

int a = objectify.begin().query().countAll();
System.out.println( a);   // 0

int b = objectify.begin().query(Contact.class).countAll();
System.out.println( b );  // 100

I would expect--according to the documentation--that the first query result 
will give me at least 100.

So sadly List<Key<Object>> listKeys = objectify.begin().query().listKeys(); 
will result in an empty list too.

Original issue reported on code.google.com by ullenb...@googlemail.com on 14 Jul 2010 at 6:02

GoogleCodeExporter commented 9 years ago
The Objectify Query simply relies on the Low-Level API Query.  You're right 
that the Objectify docs aren't exactly correct here, but unfortunately Google 
hasn't documented kind-less queries at all so I'm not entirely certain what the 
correct documentation should be.

I think the answer may be something like "kind-less queries only work when 
there is an ancestor() restriction" but it will take some experimentation to 
find out.  Would you try and let us know?

Original comment by lhori...@gmail.com on 14 Jul 2010 at 7:42

GoogleCodeExporter commented 9 years ago
If its just a 100% wrapper that this does't work, true. The Google-API for 
Query makes it clear: "Note that kindless queries are not yet supported in the 
Java dev appserver. Currently the only operations supported on a kindless query 
are filter by __key__, ancestor, and order by __key__ ascending.".

Because Objectify entities has to be registered first, my first thought was, 
that Objectify does some clever tricks of collecting these entities first. I 
was wrong :)

Original comment by ullenb...@googlemail.com on 15 Jul 2010 at 8:54

GoogleCodeExporter commented 9 years ago
I'm going to close this as not a bug.  If you think we need to somehow document 
it better in the Objectify docs, feel free to reopen it - but provide a 
suggestion as to where and what should be said.

Original comment by lhori...@gmail.com on 27 Sep 2010 at 5:53