db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer SqlBasedRsIterator.java
Date Sun, 02 Feb 2003 03:36:19 GMT
mattbaird    2003/02/01 19:36:19

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        SqlBasedRsIterator.java
  Log:
  use scrollable param for performance reasons, also use the new platform-aware close statement
in a finally block to avoid leaking.
  
  Revision  Changes    Path
  1.11      +13 -5     jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/SqlBasedRsIterator.java
  
  Index: SqlBasedRsIterator.java
  ===================================================================
  RCS file: /home/cvs//jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/SqlBasedRsIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SqlBasedRsIterator.java	15 Jan 2003 10:43:28 -0000	1.10
  +++ SqlBasedRsIterator.java	2 Feb 2003 03:36:18 -0000	1.11
  @@ -56,6 +56,7 @@
   
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
   
  @@ -81,7 +82,12 @@
           m_sql = sqlStatement;
           if (logger.isDebugEnabled())
               logger.debug("SqlBasedRsIterator(" + sqlStatement + ", " + cld + ")");
  -        m_rsAndStmt = broker.serviceJdbcAccess().executeSQL(sqlStatement, cld);
  +		/**
  +		 * MBAIRD: We should think about parameterizing this call to accept a scrollable setting
that would allow
  +		 * us to use the faster NOT_SCROLLABLE mode if the client knows he isn't going to use
any cursor control
  +		 * options.
  +		 */
  +        m_rsAndStmt = broker.serviceJdbcAccess().executeSQL(sqlStatement, cld, Query.SCROLLABLE);
           m_broker = broker;
           m_cld = cld;
           itemProxyClass = cld.getProxyClass();
  @@ -129,20 +135,22 @@
               countSql = "select count(*) " + m_sql.substring(fromPos);
           }
   
  -        rsStmt = m_broker.serviceJdbcAccess().executeSQL(countSql, m_cld);
  +        rsStmt = m_broker.serviceJdbcAccess().executeSQL(countSql, m_cld, Query.NOT_SCROLLABLE);
           try
           {
               if (rsStmt.m_rs.next())
               {
                   count = rsStmt.m_rs.getInt(1);
               }
  -            rsStmt.m_rs.close();
  -            rsStmt.m_stmt.close();
           }
           catch (SQLException e)
           {
               throw new PersistenceBrokerException(e);
           }
  +		finally
  +		{
  +			rsStmt.close();
  +		}
           return count;
       }
   }
  
  
  

Mime
View raw message