[Opensource] searchAndRetrieveList() method of MultiDBObject.java

liuhey liuhey at neusoft.com
Sun Dec 14 21:04:24 PST 2003


There is a bug in the searchAndRetrieveList() method of MultiDBObject.java.
After executing the query, it ignores the offset property when it populates the MultiDBOBject objects from myConnection. 
I think it should do this like the searchAndRetrieveList() method of DBObject.

//MultiDBObject
 public synchronized List searchAndRetrieveList() throws DBException {
            ..............
            myConnection.execute(myStatement.toString());

            int recordCount = 0;

            while (myConnection.next()) {
                MultiDBObject myObj = getThisMultiDBObj();
                recordCount++;

                if ((recordCount > maxRecords) && (maxRecords > 0)) {
                    break;
                }

                int i = 1;

                if (log.isDebugEnabled()) {
                    log.debug("Retrieved row " + recordCount);
                }

                String oneFieldValue = null;
    ......}}

//DBObject
 public synchronized List searchAndRetrieveList() throws DBException {
            ..............
            myConnection = this.createAndExecuteSearch(retrievedFieldList);

            int recordCount = 0;
            int retrieveCount = 0;

            while (myConnection.next()) {
                recordCount++;
                retrieveCount++;

                //If there's limitation syntax on, then the first record will be the
                //maximum record.
                if (retrieveCount < offsetRecord && offsetRecord > 0 &&
                        myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
                    continue;
                } else if (retrieveCount == offsetRecord && offsetRecord > 0 &&
                        myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
                    recordCount = 0; //Reset count for counting for max records.
                    continue; //Skip this record... next one, we will start loading.
                }
                if ((recordCount > maxRecords) && (maxRecords > 0)) {
                    this.setAttribute("More Records", "Y");
                    break;
                }
    ......}}



More information about the Opensource mailing list