db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r371245 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: accesslayer/RowReaderDefaultImpl.java util/SqlHelper.java
Date Sun, 22 Jan 2006 09:13:00 GMT
Author: brj
Date: Sun Jan 22 01:12:56 2006
New Revision: 371245

URL: http://svn.apache.org/viewcvs?rev=371245&view=rev
Log:
minor refoactoring

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/SqlHelper.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java?rev=371245&r1=371244&r2=371245&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RowReaderDefaultImpl.java
Sun Jan 22 01:12:56 2006
@@ -31,14 +31,12 @@
  *
  * @version $Id$
  */
-
 public class RowReaderDefaultImpl implements RowReader
 {
-    /**
+    /** 
      * Used as key in result set row map.
      */
     private static final String OJB_CONCRETE_CLASS_KEY = "ojbTemporaryNoneColumnKey";
-    public static final String OJB_CLASS_COLUMN_USED = "ojbClassColumunUsed42";
     /**
      * represents a zero sized parameter array
      */
@@ -193,7 +191,7 @@
             }
             else
             {
-                String ojbClass = getOJBClassColumnName(rs_stmt);
+                String ojbClass = SqlHelper.getOjbClassName(rs_stmt);
                 if (ojbClass != null)
                 {
                     ClassDescriptor cld = m_cld.getRepository().getDescriptorFor(ojbClass);
@@ -209,14 +207,14 @@
         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(ResultSetAndStatement rs_stmt, Map row)
     {
 
-        String ojbClass = getOJBClassColumnName(rs_stmt);
+        String ojbClass = SqlHelper.getOjbClassName(rs_stmt);
         ClassDescriptor cld;
         
         if (ojbClass != null)
@@ -323,19 +321,5 @@
     public ClassDescriptor getClassDescriptor()
     {
         return m_cld;
-    }
-
-    private String getOJBClassColumnName(ResultSetAndStatement rsAndStmt)
-    {
-        String result = null;
-        if(rsAndStmt.m_sql != null)
-        {
-            boolean b = rsAndStmt.m_sql.isUseOjbClassColumn();
-            if(b)
-            {
-                result = SqlHelper.getOjbClassName(rsAndStmt.m_rs);
-            }
-        }
-        return result;
     }
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/SqlHelper.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/SqlHelper.java?rev=371245&r1=371244&r2=371245&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/SqlHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/SqlHelper.java Sun
Jan 22 01:12:56 2006
@@ -15,10 +15,11 @@
  * limitations under the License.
  */
 
-import java.sql.ResultSet;
 import java.sql.SQLException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.ojb.broker.PersistenceBrokerException;
+import org.apache.ojb.broker.accesslayer.ResultSetAndStatement;
 
 /**
  * Helper class for all SQL related stuff.
@@ -132,16 +133,20 @@
      * @param rs the Resultset
      * @return null if the column is not available
      */
-    public static String getOjbClassName(ResultSet rs)
+    public static String getOjbClassName(ResultSetAndStatement rsAndStmt)
     {
-        try
+        String result = null;
+        if (rsAndStmt.m_sql != null && rsAndStmt.m_sql.isUseOjbClassColumn())
         {
-            return rs.getString(OJB_CLASS_COLUMN);
-        }
-        catch (SQLException e)
-        {
-            return null;
+            try
+            {
+                result = rsAndStmt.m_rs.getString(OJB_CLASS_COLUMN);
+            }
+            catch (SQLException e)
+            {
+                throw new PersistenceBrokerException("Cannot access " + OJB_CLASS_COLUMN,
e);
+            }
         }
+        return result;
     }
-
 }



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