Hello,

i'm having Problems when retrieving Results with a Reportquery.
I set the max number of results to 10 and on the 9th row my loop crashes 
(because in the database there are only 8 rows).
I would expect ojb to only return 8 Rows.

Code snippet:

var crit = new Packages.org.apache.ojb.broker.query.Criteria();
 crit.addEqualToField("logs.menuLinkId","id");
 var q = new 
Packages.org.apache.ojb.broker.query.ReportQueryByCriteria(Packages.nymphoon.MenuLink,
 
crit);
  
 var attributes = new Array(3);
 attributes[0] = "logs.menuLinkId";
     attributes[1] = "count(*)";
 attributes[2] = "name";
     q.setAttributes(attributes);
 
 q.addGroupBy("logs.menuLinkId");
 q.addGroupBy("name");
 q.addOrderByDescending("count(*)");
 q.setEndAtIndex(10);
 
 dao.begin();
     var it = dao.getReport (q);
     while ( it.hasNext() ) {
  var o = it.next(); // crash
  suggestions.add(o);
     }
     dao.commit();


The while loop crashes after the 8th Element.
An Iterator of Type broker.accesslayer.PagingIterator (it) is 
instanciated correctly.
I thought that if there are only 8 Rows it.hasNext() would return false?

I could add a try/catch in the inner loop, but i don't think this is a 
good solution.
Can anyone help me with this?

The loop works fine when i set "q.setEndAtIndex(5);" i.e.

Christoph

Attachment: pgpcucCVfioa7.pgp
Description: PGP signature

Reply via email to