You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Peter Wieland <Pe...@gmx.de> on 2004/08/10 10:21:32 UTC
strange behaviour Query.setStartAtIndex() and Query.setEndAtIndex()
Hi all,
I found something strange when using Query.setStartAtIndex(...) and
Query.setEndAtIndex(.).
The following is taken from a JUnit TestCase:
Query query = getAQuerySomeWhere();
query.setStartAtIndex(start);
query.setEndAtIndex(end);
Collection result = broker.getCollectionByQuery(query);
assertTrue("Too many results", result.size() <= end - start);
The test passes, as long as start == 0. If start > 0, the test fails (in
these cases result.size() == end - start + 1).
If I do
Query query1 = getAQuerySomewhere();
query1.setStartAtIndex(0);
query1.setEndAtIndex(10);
Collection result1 = broker.getCollectionByQuery(query1);
Query query2 = getAQuerySomewhere();
query2.setStartAtIndex(10);
query2.setEndAtIndex(20);
Collection result2 = broker.getCollectionByQuery(query2);
the last element of result1 is the same as the first element of result2.
According to the JavaDocs, the startAtIndex is inclusive, the endAtIndex
is exclusive, hence, result1 and result2 should not have common
elements.
I was using OJB 1.0rc5 with an HSQLDB database for these tests.
Any ideas?
Regards,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org