Hi liqwei,

You can get the total count of a specific query as follows:

Query query = new Query(Book.getKind());
PreparedQuery pq = ds.prepare(query);
FetchOptions option = FetchOptions.Builder.withLimit(Integer.MAX_VALUE);
out.println(pq.countEntities(option));

Hope this helps,

Yasuo Higa

On Sun, Nov 7, 2010 at 11:02 AM, liqwei <liq...@gmail.com> wrote:
> case 【PreparedQuery.countEntities()】 is Deprecated。
>
> but how can I get the Total Count of a specific Query?
>
> the  【PreparedQuery.countEntities(FetchOptions fetchOptions) 】only
> return the count specificed by fetchOptions!
>
> ex.
> Query query = new Query(Book.getKind());  // there are 3 entities with
> "Book" kind in datastore zone
> PreparedQuery pq = ds.prepare(query);
> FetchOptions option = FetchOptions.Builder.withLimit(2);
> out.println(pq.countEntities());                 // the count I really
> want, but the method is Deprecated currently;
> out.println(pq.countEntities(option));        // the count only return
> 2, but it should return 3 entity in this query;
>
> 3ks!
>
> --
> 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-j...@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-j...@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