db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer RsIterator.java ResultSetAndStatement.java PkEnumeration.java
Date Thu, 27 Nov 2003 14:50:24 GMT
arminw      2003/11/27 06:50:24

  Modified:    src/test/org/apache/ojb repository_database.xml
               src/java/org/apache/ojb/broker/accesslayer RsIterator.java
                        ResultSetAndStatement.java PkEnumeration.java
  Log:
  do call ResultSetAndStatement#close() after use
  
  Revision  Changes    Path
  1.16      +2 -2      db-ojb/src/test/org/apache/ojb/repository_database.xml
  
  Index: repository_database.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_database.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- repository_database.xml	17 Sep 2003 22:31:51 -0000	1.15
  +++ repository_database.xml	27 Nov 2003 14:50:23 -0000	1.16
  @@ -26,7 +26,7 @@
      		username="@USER_NAME@"
      		password="@USER_PASSWD@"
           eager-release="false"
  -   		batch-mode="false"
  +   		batch-mode="true"
           useAutoCommit="1"
           ignoreAutoCommitExceptions="false"
        >
  
  
  
  1.50      +21 -21    db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
  
  Index: RsIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- RsIterator.java	23 Nov 2003 09:50:44 -0000	1.49
  +++ RsIterator.java	27 Nov 2003 14:50:23 -0000	1.50
  @@ -3,9 +3,9 @@
   /*
    * ==================================================================== The
    * Apache Software License, Version 1.1
  - * 
  + *
    * Copyright (c) 2001 The Apache Software Foundation. All rights reserved.
  - * 
  + *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions are met:
    *  1. Redistributions of source code must retain the above copyright notice,
  @@ -25,7 +25,7 @@
    *  5. Products derived from this software may not be called "Apache", "Apache
    * ObjectRelationalBridge", nor may "Apache" appear in their name, without
    * prior written permission of the Apache Software Foundation.
  - * 
  + *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  @@ -37,7 +37,7 @@
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * ====================================================================
  - * 
  + *
    * This software consists of voluntary contributions made by many individuals
    * on behalf of the Apache Software Foundation. For more information on the
    * Apache Software Foundation, please see <http://www.apache.org/> .
  @@ -72,11 +72,11 @@
    * persistent objects step-by-step and not all at once. In fact the
    * PersistenceBroker::getCollectionByQuery(...) method uses a RsIterator
    * internally to build up a Collection of objects
  - * 
  + *
    * NOTE: this code uses features that only JDBC 2.0 compliant Drivers support.
    * It will NOT work with JDBC 1.0 Drivers (e.g. SUN's JdbcOdbcDriver) If you
    * are forced to use such a driver, you can use code from the 0.1.30 release.
  - * 
  + *
    * @author <a href="mailto:thma@apache.org">Thomas Mahler <a>
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird <a>- added the
    *         support for extents mapped to single table - added the .size
  @@ -108,7 +108,7 @@
       /**
   	 * the underlying query object
   	 */
  -    private org.apache.ojb.broker.accesslayer.RsQueryObject m_queryObject;
  +    private RsQueryObject m_queryObject;
   
       /**
   	 * the proxy class to be used or null
  @@ -152,11 +152,11 @@
   
       /**
   	 * RsIterator constructor.
  -	 * 
  +	 *
   	 * @param queryObject query object
   	 * @param broker the broker we should use.
   	 */
  -    public RsIterator(RsQueryObject queryObject, PersistenceBrokerImpl broker)
  +    public RsIterator(RsQueryObject queryObject, final PersistenceBrokerImpl broker)
       {
           setCache(broker.serviceObjectCache());
           setRow(new HashMap());
  @@ -225,7 +225,7 @@
           }
           if (logger.isDebugEnabled())
               logger.debug("hasNext() -> " + getHasNext());
  -        
  +
           return getHasNext();
       }
   
  @@ -255,7 +255,7 @@
                   return obj;
               }
               else
  -            {    
  +            {
                   throw new NoSuchElementException("inner hasNext was false");
               }
           }
  @@ -467,9 +467,9 @@
   
       /**
   	 * Reads primary key information from current RS row and generates a
  -	 * 
  +	 *
   	 * corresponding Identity, and returns a proxy from the Identity.
  -	 * 
  +	 *
   	 * @throws PersistenceBrokerException
   	 *             if there was an error creating the proxy class
   	 */
  @@ -486,7 +486,7 @@
   	 * with a new batch of JDBC 3.0 drivers coming out we can't just check for
   	 * begins with 2, we need to check the actual version and see if it's
   	 * greater than or equal to 2
  -	 * 
  +	 *
   	 * @return
   	 */
       private boolean supportsAdvancedJDBCCursorControl()
  @@ -502,7 +502,7 @@
   
       /**
   	 * Answer the counted size
  -	 * 
  +	 *
   	 * @return int
   	 */
       protected int countedSize() throws PersistenceBrokerException
  @@ -513,7 +513,7 @@
           int count = 0;
   
           // BRJ: do not use broker.getCount() because it's extent-aware
  -        // the count we need here must not include extents !   
  +        // the count we need here must not include extents !
           if (countQuery instanceof QueryBySQL)
           {
               String countSql = ((QueryBySQL) countQuery).getSql();
  @@ -539,7 +539,7 @@
           {
               rsStmt.close();
           }
  -        
  +
           return count;
       }
   
  @@ -617,7 +617,7 @@
   	 * number is positive, the cursor moves to the given row number with
   	 * respect to the beginning of the iterator. The first row is row 1, the
   	 * second is row 2, and so on.
  -	 * 
  +	 *
   	 * @param row
   	 *            the row to move to in this iterator, by absolute number
   	 */
  @@ -683,7 +683,7 @@
   	 * Attempting to move beyond the first/last row in the iterator positions
   	 * the cursor before/after the the first/last row. Calling relative(0) is
   	 * valid, but does not change the cursor position.
  -	 * 
  +	 *
   	 * @param row
   	 *            the row to move to in this iterator, by relative number
   	 */
  @@ -733,7 +733,7 @@
               if (!this.resourcesAreReleased)
               {
                   this.resourcesAreReleased = true;
  -                getBroker().serviceStatementManager().closeResources(getRsAndStmt().m_stmt,
getRsAndStmt().m_rs);
  +                m_rsAndStmt.close();
               }
           }
       }
  
  
  
  1.9       +4 -1      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ResultSetAndStatement.java
  
  Index: ResultSetAndStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ResultSetAndStatement.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ResultSetAndStatement.java	27 Nov 2003 12:51:53 -0000	1.8
  +++ ResultSetAndStatement.java	27 Nov 2003 14:50:23 -0000	1.9
  @@ -91,6 +91,9 @@
   
   	/**
   	 * do a platform specific resource release.
  +     * <br/>
  +     * Note: This method must be called after usage
  +     * of this class.
   	 */
   	public void close()
   	{
  
  
  
  1.13      +9 -6      db-ojb/src/java/org/apache/ojb/broker/accesslayer/PkEnumeration.java
  
  Index: PkEnumeration.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/PkEnumeration.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PkEnumeration.java	8 Jul 2003 06:05:36 -0000	1.12
  +++ PkEnumeration.java	27 Nov 2003 14:50:24 -0000	1.13
  @@ -182,10 +182,6 @@
               {
                   hasCalledCheck = true;
                   hasNext = resultSetAndStatment.m_rs.next();
  -                if (!hasNext)
  -                {
  -                    releaseDbResources();
  -                }
               }
           }
           catch (SQLException e)
  @@ -194,12 +190,19 @@
               //releaseDbResources();
               hasNext = false;
           }
  +        finally
  +        {
  +            if(!hasNext)
  +            {
  +                releaseDbResources();
  +            }
  +        }
           return hasNext;
       }
   
       private void releaseDbResources()
       {
  -        broker.serviceStatementManager().closeResources(resultSetAndStatment.m_stmt, resultSetAndStatment.m_rs);
  +        resultSetAndStatment.close();
       }
   
       /**
  
  
  

---------------------------------------------------------------------
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