Hello Ennio, I am hiting the same problem. I have only 9000 records. As you said I can retrieve them in a single call. But since I do processing which each of them I need to split it up in order not to use to much time. So I thought it would be good to use the setRange. But at a certain point it hits this magic border that you describe. I can not believe that this has been implemented so poorly. Did you find any solution to this?
Thanks, Tobias On Aug 7, 9:55 am, ennio piovesan <ennio.piove...@gmail.com> wrote: > It is not really true that queries can return at most 1000 results. I didn't > say to you that in my test application, if I setRange(0,5000) I get 5000 > entities! You can try this athttp://unaprovadiennio.appspot.com/ writing > "DISPLAY0Z5000" in the text box (you have to wait a bit). If you try > "DISPLAY1050Z1060" you get the error. > > Here the pieces of code used (it's a pie from StockWatcher sample > application): > > [when you clic the Add button] > > ... > if(symbol.startsWith("DISPLAY")){ > int posSep=symbol.indexOf("Z"); > int daOffset = Integer.parseInt(symbol.substring(7,posSep)); > int topLimit = Integer.parseInt(symbol.substring(posSep+1)); > getAllLimited(daOffset, topLimit); > return; > > } > > ... > > [ the method called getAllLimited] > > private void getAllLimited(int daOffset, int quanti) { > prodottoBaseService = GWT.create(ProdottoBaseService.class); > prodottoBaseService.getAll(Integer.valueOf(daOffset), > Integer.valueOf(quanti), new AsyncCallback<List<ProdottoBaseI>>() { > public void onFailure(Throwable error) { > Window.alert("failure " + error.getMessage()); > > } > > public void onSuccess(List<ProdottoBaseI> async) { > StringBuffer sb = new StringBuffer(); > for(ProdottoBaseI pbi:async){ > sb.append(pbi.toString()+"\n");} > > Window.alert("Totale " + async.size()+" " + sb.toString()); > > } > }); > } > > .... > > [ the method called getAll] > public List<ProdottoBaseI> getAll(Integer offset, Integer topLimit) { > PersistenceManager pm = PMF.get().getPersistenceManager(); > List<ProdottoBase> prodotti = new ArrayList<ProdottoBase>(); > List<ProdottoBaseI> prodottiDTO = new ArrayList<ProdottoBaseI>(); > try { > Query q = pm.newQuery("SELECT FROM > com.google.gwt.sample.stockwatcher.server.ProdottoBase"); > q.setOrdering("codice"); > *q.setRange(offset.longValue(), topLimit.longValue());* > prodotti = (List<ProdottoBase>) q.execute(); > for(ProdottoBase pb:prodotti){ > prodottiDTO.add(getDTOProdottoBase(pb)); > } > }finally { > pm.close(); > } > return prodottiDTO; > > } > > ... > > I read the article you suggested on paging. I can hardly speak of "best > practice". It is an (awesome) workaround. The final result is that I can't > use setRange to obtain 10 records when I look past the 1000th. > > It is promising the item in the roadmap you recall. > Let's hope the road "won't be long" ... > Thanx again. > Ennio. > > 2009/8/6 Jason (Google) <apija...@google.com>: > > > Hi. Queries can return at most 1000 results, so I believe this is the > issue > > you're experiencing -- results 1050-1060 don't exist. At most, you can use > > setRange(989, 999). > > > This is a known restriction, and there is an item in the roadmap to > address > > it: "Cursors for continuing results of Datastore queries past the 1000 > > entity limit." In the meantime, if you need paging support, the following > > article lays out the best practices that doesn't involve ranges/offsets. > The > > code in the article is Python-based, but the principle is the same. > >http://code.google.com/appengine/articles/paging.html > > Also, Extent is a part of the JDO spec so I don't know what you mean by > > saying you won't be able to use the JDO features. > > - Jason > > On Wed, Aug 5, 2009 at 12:31 AM, ennio1958 <ennio.piove...@gmail.com> > wrote: > > >> I have some problem with the usage of setRange. > >> If I setRange(0,10) all works fine, and also if I setRange(400,700), > >> but if I setRange(1050, 1060) I get a server error probably due to > >> limit/quota problems. I read some comments on this in this group, but > >> not a great sequel. If the implementation of setRange involve limit/ > >> quota even if what I expect is a 10 record list, I think it must be > >> "rethinked". > >> The workaround I read (putting a limit on a property in the where > >> clause) is poor and not always applicable because if the range is, > >> say, of 10 records and there are more than 10 entities with the same > >> value for that property, I can't paginate because of an infinite > >> loop... > >> So I think it is a serious problem, because pagination is often and > >> widely used in applications and it is mandatory a general solution, > >> not workarounds. > >> I hope someone will give a "positive" answer to this. > >> Thank you. > >> Ennio. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---