db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/test/org/apache/ojb repository_database.xml
Date Tue, 14 Jan 2003 11:23:38 GMT
arminw      2003/01/14 03:23:37

  Modified:    src/java/org/apache/ojb/broker/singlevm
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/accesslayer RsIterator.java
               src/test/org/apache/ojb repository_database.xml
  Log:
  add patch from Ron Gallagher
  - fix NullpointerException when using
  RsIterator with Oracle:
  I have a table with 2 records in it.  If I submit
  a query with the start index set to 0 and the end index set to 2 or greater,
  I get a NullPointerException with the following stack trace:
  
  - repository_database rollback sequence manager
  change
  
  Revision  Changes    Path
  1.111     +32 -4     jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java,v
  retrieving revision 1.110
  retrieving revision 1.111
  diff -u -r1.110 -r1.111
  --- PersistenceBrokerImpl.java	11 Jan 2003 19:48:37 -0000	1.110
  +++ PersistenceBrokerImpl.java	14 Jan 2003 11:23:36 -0000	1.111
  @@ -1242,8 +1242,13 @@
                * keep retrieving objects while retrievedCount is less than the retrievalCount,
or the
                * retrievalCount is -1 meaning get all results.
                * be sure not to go over the actual size of the iterator.
  +             *
  +             * Note: The call to iter.hasNext appears in this condition AFTER we check
to
  +             * see if we should exit the loop due to the fact that we have processed
  +             * enough records.  This way, when we process an adequate number of records,
  +             * we'll exit the loop without calling hasNext one extra time.
                */
  -            while (iter.hasNext() && ((endAt == Query.NO_END_AT_INDEX) || (retrievedCount
< numberOfObjectsToFetch)))
  +            while (((endAt == Query.NO_END_AT_INDEX) || (retrievedCount < numberOfObjectsToFetch))
&& iter.hasNext())
               {
                   Object candidate = iter.next();
                   /**
  @@ -1264,7 +1269,26 @@
                   }
               }
               /**
  -             * set full size of query to pass back to client.
  +             * Set full size of query to pass back to client.
  +             *
  +             * If the user did not specify the start or end index, then
  +             * set the full size of the query to the number of records
  +             * we retrieved.
  +             *
  +             * If the user specified either of the indices, then we need to
  +             * look at the number of records that were actually requested.
  +             * If the user requested more records than were available, then
  +             * the full size of the query is the actual number of records that
  +             * we processed plus the number of records we skipped at the
  +             * beginning.  We must calculate the full size of the query in this
  +             * manner because of the fact that we'll exit the "while" loop
  +             * above when iter.hasNext() returns false.  However, that last
  +             * call to iter.hasNext() will close the underlying cursor, making
  +             * it unavailable during the call to iter.size().
  +             *
  +             * If the user requested fewer records than are availble in the
  +             * query, then we can simply call the iter.size() method to get the
  +             * full size of the query.
                */
               if ((startAt == Query.NO_START_AT_INDEX)
                       && (endAt == Query.NO_END_AT_INDEX))
  @@ -1273,7 +1297,11 @@
               }
               else
               {
  -                query.fullSize(iter.size());
  +                if (numberOfObjectsToFetch > retrievedCount ) {
  +                    query.fullSize(retrievedCount + query.getStartAtIndex());
  +                } else {
  +                    query.fullSize(iter.size());
  +                }
               }
           }
           catch (InstantiationException ex)
  
  
  
  1.26      +13 -2     jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
  
  Index: RsIterator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- RsIterator.java	9 Jan 2003 16:57:21 -0000	1.25
  +++ RsIterator.java	14 Jan 2003 11:23:37 -0000	1.26
  @@ -152,6 +152,12 @@
   	private boolean JDBCSupportAssessed = false;
   	private Query m_query = null;
       private int m_current_row = 0;
  +    /**
  +     * Tracks whether or not the resources that are used by this
  +     * class have been released.
  +     */
  +    private boolean resourcesAreReleased = false;
  +
   
       protected RsIterator()
       {
  @@ -650,7 +656,11 @@
   	{
           if (!inBatchedMode)     // resources are reused in batched mode
           {
  -		  m_broker.serviceStatementManager().closeResources(m_rsAndStmt.m_stmt, m_rsAndStmt.m_rs);
  +            // If we haven't released resources yet, then do so.
  +            if (!this.resourcesAreReleased) {
  +                this.resourcesAreReleased = true;
  +                m_broker.serviceStatementManager().closeResources(m_rsAndStmt.m_stmt, m_rsAndStmt.m_rs);
  +             }
           }
   	}
   
  @@ -667,3 +677,4 @@
           return m_broker.serviceConnectionManager().getConnectionDescriptor();
       }
   }
  +
  
  
  
  1.8       +1 -1      jakarta-ojb/src/test/org/apache/ojb/repository_database.xml
  
  Index: repository_database.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/repository_database.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- repository_database.xml	14 Jan 2003 11:16:19 -0000	1.7
  +++ repository_database.xml	14 Jan 2003 11:23:37 -0000	1.8
  @@ -33,7 +33,7 @@
               maxActive="21"
               validationQuery="" />
   
  -        <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerInMemoryImpl">
  +        <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
               <attribute attribute-name="grabSize" attribute-value="20"/>
           </sequence-manager>
      </jdbc-connection-descriptor>
  
  
  

Mime
View raw message