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 JdbcAccessImpl.java ProxyRsIterator.java ResultSetAndStatement.java RowReader.java RowReaderDefaultImpl.java RsIterator.java
Date Fri, 30 Sep 2005 01:46:44 GMT
arminw      2005/09/29 18:46:44

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SelectStatementWrapper.java SqlGenerator.java
                        SqlGeneratorDefaultImpl.java
               src/java/org/apache/ojb/broker/accesslayer
                        JdbcAccessImpl.java ProxyRsIterator.java
                        ResultSetAndStatement.java RowReader.java
                        RowReaderDefaultImpl.java RsIterator.java
  Log:
  consistent use of SelectStatementWrapper in SqlGenerator
  consistent use of ResultSetAndStatement in RowReader
  
  Revision  Changes    Path
  1.2       +34 -15    db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SelectStatementWrapper.java
  
  Index: SelectStatementWrapper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SelectStatementWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SelectStatementWrapper.java	29 Sep 2005 20:36:41 -0000	1.1
  +++ SelectStatementWrapper.java	30 Sep 2005 01:46:44 -0000	1.2
  @@ -15,9 +15,9 @@
    * limitations under the License.
    */
   
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.metadata.JdbcType;
  +import org.apache.ojb.broker.query.Query;
   
   
   /**
  @@ -27,29 +27,37 @@
    * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
    * @version $Id$
    */
  -public class SelectStatementWrapper implements SqlStatement
  +final public class SelectStatementWrapper implements SqlStatement
   {
  -    private String sql;
  -    private FieldDescriptor[] selectedFields;
  -    private ClassDescriptor[] classDescriptors; 
  +    private final String sql;
  +    private final FieldDescriptor[] selectedFields;
  +    //private final ClassDescriptor[] classDescriptors;
  +    private final Query query;
   
  -    public SelectStatementWrapper(SqlStatement aStatement)
  +    public SelectStatementWrapper(Query query, SqlStatement aStatement)
       {
  +        this.query = query;
           sql = aStatement.getStatement();
  -        
  +
           if (aStatement instanceof SqlSelectStatement)
           {
               SqlSelectStatement selectStmt = (SqlSelectStatement) aStatement;
               selectedFields = selectStmt.getFieldsForSelect();
  -            classDescriptors = selectStmt.getMultiJoinedClassDescriptors();           

  +            //classDescriptors = selectStmt.getMultiJoinedClassDescriptors();
  +        }
  +        else
  +        {
  +            selectedFields = null;
  +            //classDescriptors = null;
           }
       }
   
  -    public SelectStatementWrapper(SqlSelectStatement aStatement)
  +    public SelectStatementWrapper(Query query, SqlSelectStatement aStatement)
       {
  +        this.query = query;
           sql = aStatement.getStatement();
           selectedFields = aStatement.getFieldsForSelect();
  -        classDescriptors = aStatement.getMultiJoinedClassDescriptors();
  +        //classDescriptors = aStatement.getMultiJoinedClassDescriptors();
       }
   
       /**
  @@ -60,9 +68,20 @@
           return sql;
       }
   
  -    public ClassDescriptor[] getClassDescriptors()
  +//    public ClassDescriptor[] getClassDescriptors()
  +//    {
  +//        return classDescriptors;
  +//    }
  +
  +    /**
  +     * Get the {@link org.apache.ojb.broker.query.Query}
  +     * this statement wrapper instance based on.
  +     *
  +     * @return The underlying {@link org.apache.ojb.broker.query.Query}.
  +     */
  +    public Query getQuery()
       {
  -        return classDescriptors;
  +        return query;
       }
   
       /**
  @@ -73,7 +92,7 @@
       public int getColumnIndex(FieldDescriptor fld)
       {
           int index = JdbcType.MIN_INT;
  -        
  +
           if (selectedFields != null)
           {
               for (int i = 0; i < selectedFields.length; i++)
  @@ -85,7 +104,7 @@
                   }
               }
           }
  -        
  +
           return index;
       }
   }
  
  
  
  1.14      +4 -4      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGenerator.java
  
  Index: SqlGenerator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGenerator.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SqlGenerator.java	29 Sep 2005 20:36:41 -0000	1.13
  +++ SqlGenerator.java	30 Sep 2005 01:46:44 -0000	1.14
  @@ -55,14 +55,14 @@
        * @param query the Query
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectStatement(Query query, ClassDescriptor cld);
  +    public SelectStatementWrapper getPreparedSelectStatement(Query query, ClassDescriptor
cld);
   
       /**
        * generate a select pk-columns only statement according to query
        * @param query the Query
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectPkStatement(Query query, ClassDescriptor cld);
  +    public SelectStatementWrapper getPreparedSelectPkStatement(Query query, ClassDescriptor
cld);
   
       /**
        * generate a select-Statement according to query
  @@ -97,7 +97,7 @@
        * described by cld
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectByPkStatement(ClassDescriptor cld);
  +    public SelectStatementWrapper getPreparedSelectByPkStatement(ClassDescriptor cld);
   
       /**
        * generate a prepared UPDATE-Statement for the Class
  
  
  
  1.33      +7 -8      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
  
  Index: SqlGeneratorDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- SqlGeneratorDefaultImpl.java	29 Sep 2005 20:36:41 -0000	1.32
  +++ SqlGeneratorDefaultImpl.java	30 Sep 2005 01:46:44 -0000	1.33
  @@ -201,14 +201,13 @@
        *
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectByPkStatement(ClassDescriptor cld)
  +    public SelectStatementWrapper getPreparedSelectByPkStatement(ClassDescriptor cld)
       {
           SqlForClass sfc = getSqlForClass(cld);
           SqlStatement result = sfc.getSelectByPKSql();
           if(result == null)
           {
               ProcedureDescriptor pd = cld.getSelectByPKProcedure();
  -            SqlStatement sql;
   
               if(pd == null)
               {
  @@ -227,7 +226,7 @@
                   m_logger.debug("SQL:" + result);
               }
           }
  -        return new SelectStatementWrapper(result);
  +        return new SelectStatementWrapper(null, result);
       }
   
       /**
  @@ -236,7 +235,7 @@
        * @param query the Query
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectStatement(Query query, ClassDescriptor cld)
  +    public SelectStatementWrapper getPreparedSelectStatement(Query query, ClassDescriptor
cld)
       {
           ProcedureDescriptor pd = cld.getSelectByFKProcedure();
           SqlStatement sql;
  @@ -252,7 +251,7 @@
               sql = new SqlSelectStatement(m_platform, m_logger, cld, query);
           }
   
  -        return new SelectStatementWrapper(sql);
  +        return new SelectStatementWrapper(query, sql);
       }
   
       /**
  @@ -261,12 +260,12 @@
        * @param query the Query
        * @param cld the ClassDescriptor
        */
  -    public SqlStatement getPreparedSelectPkStatement(Query query, ClassDescriptor cld)
  +    public SelectStatementWrapper getPreparedSelectPkStatement(Query query, ClassDescriptor
cld)
       {
           SqlStatement sql;
           sql = new SqlSelectPkStatement(m_platform, m_logger, cld, query);
   
  -        return new SelectStatementWrapper(sql);
  +        return new SelectStatementWrapper(query, sql);
       }
   
       /**
  
  
  
  1.36      +10 -8     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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- JdbcAccessImpl.java	29 Sep 2005 20:36:41 -0000	1.35
  +++ JdbcAccessImpl.java	30 Sep 2005 01:46:44 -0000	1.36
  @@ -32,6 +32,7 @@
   import org.apache.ojb.broker.PersistenceBrokerSQLException;
   import org.apache.ojb.broker.accesslayer.sql.SqlExistStatement;
   import org.apache.ojb.broker.accesslayer.sql.SqlStatement;
  +import org.apache.ojb.broker.accesslayer.sql.SelectStatementWrapper;
   import org.apache.ojb.broker.core.ValueContainer;
   import org.apache.ojb.broker.metadata.ArgumentDescriptor;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  @@ -300,7 +301,7 @@
           try
           {
               final int queryFetchSize = query.getFetchSize();
  -            final SqlStatement sql;
  +            final SelectStatementWrapper sql;
               if (selectPkOnly)
               {
                   sql = broker.serviceSqlGenerator().getPreparedSelectPkStatement(query,
cld);
  @@ -664,11 +665,12 @@
       public Object materializeObject(ClassDescriptor cld, Identity oid)
           throws PersistenceBrokerException
       {
  -        ResultSet rs = null;
  -        PreparedStatement stmt = null;
  +        ResultSetAndStatement rs_stmt = null;
           try
           {
  -            final SqlStatement sql = broker.serviceSqlGenerator().getPreparedSelectByPkStatement(cld);
  +            ResultSet rs;
  +            PreparedStatement stmt;
  +            final SelectStatementWrapper sql = broker.serviceSqlGenerator().getPreparedSelectByPkStatement(cld);
               final boolean callableStmt = SqlHelper.isStoredProcedure(sql.getStatement());
               stmt = broker.serviceStatementManager().getSelectByPKStatement(cld);
               if (stmt == null)
  @@ -694,8 +696,8 @@
               {
                   Map row = new HashMap();
                   RowReader rowReader = broker.getRowReaderFor(cld);
  -
  -                rowReader.readObjectArrayFrom(rs, row);
  +                rs_stmt = new ResultSetAndStatement(broker.serviceStatementManager(), stmt,
rs, sql);
  +                rowReader.readObjectArrayFrom(rs_stmt, row);
                   return rowReader.readObjectFrom(row);
               }
               else
  @@ -722,7 +724,7 @@
           }
           finally
           {
  -            broker.serviceStatementManager().closeResources(stmt, rs);
  +            if(rs_stmt != null) rs_stmt.close();
           }
       }
   
  
  
  
  1.3       +2 -2      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ProxyRsIterator.java
  
  Index: ProxyRsIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ProxyRsIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProxyRsIterator.java	27 Apr 2005 19:21:52 -0000	1.2
  +++ ProxyRsIterator.java	30 Sep 2005 01:46:44 -0000	1.3
  @@ -47,7 +47,7 @@
   
           // provide m_row with primary key data of current row
           RowReader reader = getBroker().getRowReaderFor(getQueryObject().getClassDescriptor());
  -        reader.readPkValuesFrom(getRsAndStmt().m_rs, getRow());
  +        reader.readPkValuesFrom(getRsAndStmt(), getRow());
   
           // assert: m_row is filled with primary key values from db
           // 1. get Identity of current row:
  
  
  
  1.16      +5 -5      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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ResultSetAndStatement.java	29 Sep 2005 20:36:41 -0000	1.15
  +++ ResultSetAndStatement.java	30 Sep 2005 01:46:44 -0000	1.16
  @@ -18,7 +18,7 @@
   import java.sql.ResultSet;
   import java.sql.Statement;
   
  -import org.apache.ojb.broker.accesslayer.sql.SqlStatement;
  +import org.apache.ojb.broker.accesslayer.sql.SelectStatementWrapper;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   
  @@ -27,7 +27,7 @@
    *
    * @version $Id$
    */
  -public class ResultSetAndStatement
  +final public class ResultSetAndStatement
   {
   	private static Logger log = LoggerFactory.getLogger(ResultSetAndStatement.class);
   
  @@ -39,9 +39,9 @@
       */
   	public final ResultSet m_rs;
   	public final Statement m_stmt;
  -    public final SqlStatement m_sql;
  +    public final SelectStatementWrapper m_sql;
   
  -	public ResultSetAndStatement(StatementManager manager, Statement stmt, ResultSet rs, SqlStatement
sql)
  +	public ResultSetAndStatement(StatementManager manager, Statement stmt, ResultSet rs, SelectStatementWrapper
sql)
   	{
   		this.manager = manager;
           m_stmt = stmt;
  
  
  
  1.12      +78 -80    db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReader.java
  
  Index: RowReader.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RowReader.java	29 Sep 2005 20:36:41 -0000	1.11
  +++ RowReader.java	30 Sep 2005 01:46:44 -0000	1.12
  @@ -1,80 +1,78 @@
  -package org.apache.ojb.broker.accesslayer;
  -
  -/* Copyright 2002-2004 The Apache Software Foundation
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *     http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
  -
  -import java.io.Serializable;
  -import java.sql.ResultSet;
import java.util.Map;
  -
  -/**
  - * @version $Id$
  - */
  -public interface RowReader extends Serializable
  -{
  -	static final long serialVersionUID = -1283322922537162249L;
  -
  -    /**
  -     * Materialize a single object from the values of the Map row.
  -     * the implementor of this class must not care for materializing
  -     * references or collection attributes, this is done later!
  -     * @param row the Map containing the new values
  -     * @return a properly created instance.
  -     */
  -    public Object readObjectFrom(Map row);
  -
  -    /**
  -     * refresh an existing instance from the values of the Map row.
  -     * @param instance the instance to refresh
  -     * @param row the Map containing the new values
  -     */
  -    public void refreshObject(Object instance, Map row);
  -
  -
  -	/**
  -	 * Read all fields from the current ResultRow into the Object[] row.#
  -	 * ConversionStrategies are applied here!
  -	 */
  -	public void readObjectArrayFrom(ResultSet rs, Map row);
  -
  -    /**
  -     * Read all fields from the current ResultRow into the Object[] row.#
  -     * ConversionStrategies are applied here!
  -     */
  -    public void readObjectArrayFrom(ResultSetAndStatement rs, Map row);
  -
  -	/**
  -	 * Read primary key fields from the current ResultRow into the Object[] row.#
  -	 * ConversionStrategies are applied here!
  -	 */
  -	public void readPkValuesFrom(ResultSet rs, Map row);
  -
  -    /**
  -     * Read primary key fields from the current ResultRow into the Object[] row.#
  -     * ConversionStrategies are applied here!
  -     */
  -    public void readPkValuesFrom(ResultSetAndStatement rs, Map row);
  -
  -    /**
  -     * Set the descriptor this <i>RowReader</i> worked with.
  -     */
  -    public void setClassDescriptor(ClassDescriptor cld);
  -
  -    /**
  -     * Returns the associated {@link org.apache.ojb.broker.metadata.ClassDescriptor}
  -     */
  -    public ClassDescriptor getClassDescriptor();
  -}
  +package org.apache.ojb.broker.accesslayer;
  +
  +/* Copyright 2002-2004 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +import java.io.Serializable;
  +import java.util.Map;
  +
  +/**
  + * @version $Id$
  + */
  +public interface RowReader extends Serializable
  +{
  +//	static final long serialVersionUID = -1283322922537162249L;
  +
  +    /**
  +     * Materialize a single object from the values of the Map row.
  +     * the implementor of this class must not care for materializing
  +     * references or collection attributes, this is done later!
  +     * @param row the Map containing the new values
  +     * @return a properly created instance.
  +     */
  +    public Object readObjectFrom(Map row);
  +
  +    /**
  +     * refresh an existing instance from the values of the Map row.
  +     * @param instance the instance to refresh
  +     * @param row the Map containing the new values
  +     */
  +    public void refreshObject(Object instance, Map row);
  +
  +
  +//	/**
  +//	 * Read all fields from the current ResultRow into the Object[] row.#
  +//	 * ConversionStrategies are applied here!
  +//	 */
  +//	public void readObjectArrayFrom(ResultSet rs, Map row);
  +
  +    /**
  +     * Read all fields from the current ResultRow into the Object[] row.#
  +     * ConversionStrategies are applied here!
  +     */
  +    public void readObjectArrayFrom(ResultSetAndStatement rs, Map row);
  +
  +//	/**
  +//	 * Read primary key fields from the current ResultRow into the Object[] row.#
  +//	 * ConversionStrategies are applied here!
  +//	 */
  +//	public void readPkValuesFrom(ResultSet rs, Map row);
  +
  +    /**
  +     * Read primary key fields from the current ResultRow into the Object[] row.#
  +     * ConversionStrategies are applied here!
  +     */
  +    public void readPkValuesFrom(ResultSetAndStatement rs, Map row);
  +
  +//    /**
  +//     * Set the descriptor this <i>RowReader</i> worked with.
  +//     */
  +//    public void setClassDescriptor(ClassDescriptor cld);
  +//
  +//    /**
  +//     * Returns the associated {@link org.apache.ojb.broker.metadata.ClassDescriptor}
  +//     */
  +//    public ClassDescriptor getClassDescriptor();
  +}
  
  
  
  1.40      +20 -33    db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
  
  Index: RowReaderDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- RowReaderDefaultImpl.java	29 Sep 2005 20:36:41 -0000	1.39
  +++ RowReaderDefaultImpl.java	30 Sep 2005 01:46:44 -0000	1.40
  @@ -58,7 +58,6 @@
   
       /** The object factory to be used by this row reader for classes that require it */
       private transient ObjectFactory factory;
  -    private SelectStatementWrapper statementWrapper;
   
       public RowReaderDefaultImpl(ObjectFactory factory, ClassDescriptor classDescriptor)
       {
  @@ -166,7 +165,7 @@
   
       /**
        * Creates a new instance for the given class dscriptor.
  -     * 
  +     *
        * @param row       The row to get parameter values for the construction
        * @param classDesc The class descriptor
        * @return The new instance
  @@ -210,7 +209,7 @@
   
       /**
        * Filters the field descriptors so that the fields used as creation parameters are
not in the array.
  -     * 
  +     *
        * @param fieldDescs   The original field descriptors
        * @param creationDesc The creation descriptor
        * @return The filtered list
  @@ -235,12 +234,6 @@
           return (FieldDescriptor[])result.values().toArray(new FieldDescriptor[result.size()]);
       }
   
  -    public void readObjectArrayFrom(ResultSetAndStatement rs, Map row)
  -    {
  -        statementWrapper = (SelectStatementWrapper) rs.m_sql;
  -        readObjectArrayFrom(rs.m_rs, row);
  -    }
  -
       /**
        * materialize a single object, described by cld,
        * from the first row of the ResultSet rs.
  @@ -259,7 +252,7 @@
        *
        * @throws PersistenceBrokerException if there is an error accessing the access layer
        */
  -    public void readObjectArrayFrom(ResultSet rs, Map row)
  +    public void readObjectArrayFrom(ResultSetAndStatement rs_stmt, Map row)
       {
           FieldDescriptor[] fields;
   /*
  @@ -276,7 +269,7 @@
           }
           else
           {
  -            String ojbDiscriminator = extractOjbConcreteClass(classDescriptor, rs, row);
  +            String ojbDiscriminator = extractOjbConcreteClass(classDescriptor, rs_stmt.m_rs,
row);
               /*
               arminw:
               if multiple classes were mapped to the same table, lookup the concrete
  @@ -290,7 +283,7 @@
               }
               else
               {
  -                String ojbClass = SqlHelper.getOjbClassName(rs);
  +                String ojbClass = SqlHelper.getOjbClassName(rs_stmt.m_rs);
                   if (ojbClass != null)
                   {
                       ClassDescriptor cld = classDescriptor.getRepository().getDescriptorFor(ojbClass);
  @@ -300,21 +293,21 @@
                   else
                   {
                       fields = classDescriptor.getFieldDescriptor(true);
  -                }           
  +                }
               }
           }
  -        readValuesFrom(rs, row, fields);
  +        readValuesFrom(rs_stmt, row, fields);
       }
   
       /*
        * @see RowReader#readPkValuesFrom(ResultSet, ClassDescriptor, Map)
        * @throws PersistenceBrokerException if there is an error accessing the access layer
        */
  -    public void readPkValuesFrom(ResultSet rs, Map row)
  -    {       
  -        String ojbClass = SqlHelper.getOjbClassName(rs);
  +    public void readPkValuesFrom(ResultSetAndStatement rs_stmt, Map row)
  +    {
  +        String ojbClass = SqlHelper.getOjbClassName(rs_stmt.m_rs);
           ClassDescriptor cld;
  -        
  +
           if (ojbClass != null)
           {
               cld = classDescriptor.getRepository().getDescriptorFor(ojbClass);
  @@ -325,28 +318,22 @@
           }
   
           FieldDescriptor[] pkFields = cld.getPkFields();
  -        readValuesFrom(rs, row, pkFields);
  +        readValuesFrom(rs_stmt, row, pkFields);
       }
   
  -    public void readPkValuesFrom(ResultSetAndStatement rs, Map row)
  -    {
  -        statementWrapper = (SelectStatementWrapper) rs.m_sql;
  -        readPkValuesFrom(rs.m_rs, row);
  -    }
  -    
  -    private int getColumnIndex(FieldDescriptor fld)
  +    private int getColumnIndex(SelectStatementWrapper statementWrapper, FieldDescriptor
fld)
       {
           int index = JdbcType.MIN_INT;
  -        
  +
           if (statementWrapper != null)
           {
               index = statementWrapper.getColumnIndex(fld);
           }
  -        
  +
           return index;
       }
   
  -    protected void readValuesFrom(ResultSet rs, Map row, FieldDescriptor[] fields)
  +    protected void readValuesFrom(ResultSetAndStatement rs_stmt, Map row, FieldDescriptor[]
fields)
       {
           int size = fields.length;
           Object val;
  @@ -358,13 +345,13 @@
                   fld = fields[j];
                   if(!row.containsKey(fld.getColumnName()))
                   {
  -                    int idx = getColumnIndex(fld);
  -                    val = fld.getJdbcType().getObjectFromColumn(rs, null, fld.getColumnName(),
idx);
  +                    int idx = getColumnIndex(rs_stmt.m_sql, fld);
  +                    val = fld.getJdbcType().getObjectFromColumn(rs_stmt.m_rs, null, fld.getColumnName(),
idx);
                       row.put(fld.getColumnName(), fld.getFieldConversion().sqlToJava(val));
                   }
               }
           }
  -        catch (SQLException t)
  +        catch (Exception t)
           {
               throw new PersistenceBrokerException("Error reading class '"
                       + (fld != null ? fld.getClassDescriptor().getClassNameOfObject() :
classDescriptor.getClassNameOfObject())
  
  
  
  1.79      +2 -2      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.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- RsIterator.java	29 Sep 2005 20:36:41 -0000	1.78
  +++ RsIterator.java	30 Sep 2005 01:46:44 -0000	1.79
  @@ -475,7 +475,7 @@
               if (cld.isAlwaysRefresh())
               {
                   // map all field values from the current result set
  -                reader.readObjectArrayFrom(getRsAndStmt().m_rs, getRow());
  +                reader.readObjectArrayFrom(getRsAndStmt(), getRow());
                   reader.refreshObject(result, getRow());
               }
               getBroker().refreshRelationships(result, oid, cld);
  
  
  

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