db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitriy S. Romanov" <droma...@softline.kiev.ua>
Subject bug in PersistentBrokerImpl
Date Tue, 15 Jul 2003 17:26:58 GMT
Hello All!

I'm using OJB 1.0rc3
I've just found a little bug in org.apache.ojb.broker.core.PersistenceBrokerImpl, version:

$Id: PersistenceBrokerImpl.java,v 1.6 2003/05/04 11:06:04 thma Exp $

It is all about incorrect determining fullSize of  collection of retrieved objects  in getCollectionByQuery(Class
collectionClass, Class itemClass, Query query).

If the user requested more records than were available, fullSize is calculated as 
retrievedCount + query.getStartAtIndex()
which caused to greater fullSize than it really was.
E.g. startAtIndex=13 and there are 13 objects in collection, so 1 object is retrived and fullSize
will be 14.

Here is my fix of this bug.
    
diff PersistenceBrokerImpl.java PersistenceBrokerImpl_fixed.java
1393,1395c1393,1405
<                 if (numberOfObjectsToFetch > retrievedCount ) {
<                     query.fullSize(retrievedCount + query.getStartAtIndex());
<                 } else {
---
>                 if (numberOfObjectsToFetch > retrievedCount )
>                 {
>                                       if (startAt != Query.NO_START_AT_INDEX)
>                                       {
>                                               query.fullSize(retrievedCount + query.getStartAtIndex()
- 1);
>                                       }
>                                       else
>                                       {
>                                               query.fullSize(retrievedCount);
>                                       }
>                   }
>                   else
>                   {

--
Dmitriy S. Romanov
mailto:rds@astral.ntu-kpi.kiev.ua;dromanov@softline.kiev.ua
ICQ# 52449008


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message