db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer JdbcAccessImpl.java
Date Sun, 16 Nov 2003 20:32:41 GMT
brj         2003/11/16 12:32:41

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        JdbcAccessImpl.java
  Log:
  added support for LIMIT
  
  Revision  Changes    Path
  1.13      +39 -67    db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java
  
  Index: JdbcAccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/JdbcAccessImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JdbcAccessImpl.java	11 Nov 2003 00:07:04 -0000	1.12
  +++ JdbcAccessImpl.java	16 Nov 2003 20:32:41 -0000	1.13
  @@ -275,75 +275,48 @@
        * @param query the query string.
        * @param cld ClassDescriptor providing JDBC information.
        */
  -    public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld)
  -        throws PersistenceBrokerException
  +    public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld) throws
PersistenceBrokerException
       {
  -        if(logger.isDebugEnabled()) logger.safeDebug("executeQuery", query);
  +        if (logger.isDebugEnabled())
  +            logger.safeDebug("executeQuery", query);
   
  -        ResultSetAndStatement retval =
  -            new ResultSetAndStatement(broker.serviceConnectionManager().getSupportedPlatform());
  -        /**
  -         * MBAIRD:
  -         * we should create a scrollable resultset if the start at index or end at index
is set
  -         */
  -        boolean scrollable =
  -            ((query.getStartAtIndex() > Query.NO_START_AT_INDEX)
  -                || (query.getEndAtIndex() > Query.NO_END_AT_INDEX));
  -        /**
  -         * OR if the prefetching of relationships is being used.
  -         */
  -        if (query != null
  -            && query.getPrefetchedRelationships() != null
  -            && !query.getPrefetchedRelationships().isEmpty())
  +        ResultSetAndStatement retval = new ResultSetAndStatement(broker.serviceConnectionManager().getSupportedPlatform());
  +        /*
  +		 * MBAIRD: we should create a scrollable resultset if the start at
  +		 * index or end at index is set
  +		 */
  +        boolean scrollable = ((query.getStartAtIndex() > Query.NO_START_AT_INDEX) ||
(query.getEndAtIndex() > Query.NO_END_AT_INDEX));
  +        /*
  +		 * OR if the prefetching of relationships is being used.
  +		 */
  +        if (query != null && query.getPrefetchedRelationships() != null &&
!query.getPrefetchedRelationships().isEmpty())
           {
               scrollable = true;
           }
  +        
           try
           {
  -            // if query has criteria, use them in where clause
  -            if (query.getCriteria() != null)
  -            {
  -                String sql =
  -                    this.broker.serviceSqlGenerator().getPreparedSelectStatement(query,
cld);
  -                PreparedStatement stmt =
  -                    broker.serviceStatementManager().getPreparedStatement(cld, sql, scrollable);
  -
  -                broker.serviceStatementManager().bindStatement(stmt, query, cld, 1);
  -                if (logger.isDebugEnabled())
  -                    logger.debug("executeQuery: " + stmt);
  +            String sql = broker.serviceSqlGenerator().getPreparedSelectStatement(query,
cld);
  +            PreparedStatement stmt = broker.serviceStatementManager().getPreparedStatement(cld,
sql, scrollable);
   
  -                ResultSet rs = stmt.executeQuery();
  -                // as we return the resultset for further operations, we cannot release
the statement yet.
  -                // that has to be done by the JdbcAccess-clients (i.e. RsIterator, ProxyRsIterator
and PkEnumeration.)
  -                retval.m_rs = rs;
  -                retval.m_stmt = stmt;
  -                return retval;
  +            broker.serviceStatementManager().bindStatement(stmt, query, cld, 1);
  +            if (logger.isDebugEnabled())
  +                logger.debug("executeQuery: " + stmt);
   
  -            }
  -            // if query has no criteria, perform select * from table
  -            else
  -            {
  -                String sql = this.broker.serviceSqlGenerator().getSelectStatementDep(query,
cld);
  -                PreparedStatement stmt =
  -                    this.broker.serviceStatementManager().getPreparedStatement(
  -                        cld,
  -                        sql,
  -                        scrollable);
  -                ResultSet rs = stmt.executeQuery();
  -                retval.m_rs = rs;
  -                retval.m_stmt = stmt;
  -                return retval;
  -            }
  +            ResultSet rs = stmt.executeQuery();
  +            retval.m_rs = rs;
  +            retval.m_stmt = stmt;
  +            return retval;
           }
           catch (PersistenceBrokerException e)
           {
  -            logger.error(
  -                "PersistenceBrokerException during the execution of the query: " + e.getMessage(),
  -                e);
  -            /**
  -             * MBAIRD: error condition could result in our ResultSetAndStatement not being
returned, and not being closed
  -             * since it is opened before the try loop, we should release it if there is
a problem.
  -             */
  +            logger.error("PersistenceBrokerException during the execution of the query:
" + e.getMessage(), e);
  +            /*
  +			 * MBAIRD: error condition could result in our
  +			 * ResultSetAndStatement not being returned, and not being closed
  +			 * since it is opened before the try loop, we should release it if
  +			 * there is a problem.
  +			 */
               if (retval != null)
               {
                   retval.close();
  @@ -353,15 +326,14 @@
           catch (SQLException e)
           {
               logger.error(
  -                "SQLException during the execution of the query (for a "
  -                    + cld.getClassOfObject().getName()
  -                    + "): "
  -                    + e.getMessage(),
  +                "SQLException during the execution of the query (for a " + cld.getClassOfObject().getName()
+ "): " + e.getMessage(),
                   e);
  -            /**
  -             * MBAIRD: error condition could result in our ResultSetAndStatement not being
returned, and not being closed
  -             * since it is opened before the try loop, we should release it if there is
a problem.
  -             */
  +            /*
  +			 * MBAIRD: error condition could result in our
  +			 * ResultSetAndStatement not being returned, and not being closed
  +			 * since it is opened before the try loop, we should release it if
  +			 * there is a problem.
  +			 */
               if (retval != null)
               {
                   retval.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