db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r410617 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
Date Wed, 31 May 2006 18:03:47 GMT
Author: arminw
Date: Wed May 31 11:03:47 2006
New Revision: 410617

URL: http://svn.apache.org/viewvc?rev=410617&view=rev
Log:
fix, avoid additional lob-query, use current result set to read locator columns

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java?rev=410617&r1=410616&r2=410617&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
Wed May 31 11:03:47 2006
@@ -483,16 +483,15 @@
                              */
                             // fill reference and collection attributes
                             ClassDescriptor cld = pb.getClassDescriptor(result.getClass());
-                            // don't force loading of reference
-                            final boolean unforced = false;
-                            // Maps ReferenceDescriptors to HashSets of owners
-                            pb.getReferenceBroker().retrieveReferences(result, cld, unforced);
-                            pb.getReferenceBroker().retrieveCollections(result, cld, unforced);
 
                             // TODO: Wrap LOB-fields in RowReader in next major version
                             // wrap LOB fields
                             pb.serviceLobHelper().wrapLobFields(cld, result);
 
+                            // don't force loading of reference
+                            pb.getReferenceBroker().retrieveReferences(result, cld, false);
+                            pb.getReferenceBroker().retrieveCollections(result, cld, false);
+
                             getCache().disableMaterializationCache();
                         }
                         catch(RuntimeException e)
@@ -507,8 +506,10 @@
             else // Object is in cache
             {
                 ClassDescriptor cld = pb.getClassDescriptor(result.getClass());
-                // if refresh is required, read all values from the result set and
-                // update the cache instance from the db
+                /*
+                if refresh is required, read all values from the result set and
+                update the cache instance from the db
+                */
                 if (cld.isAlwaysRefresh())
                 {
                     // map all field values from the current result set
@@ -519,10 +520,14 @@
                     // wrap LOB fields
                     pb.serviceLobHelper().wrapLobFields(cld, result);
                 }
-                else
+                else if(cld.hasLobField() && pb.serviceLobHelper().isLobAutoRefresh())
                 {
-                    // refresh LOB fields
-                    pb.serviceLobHelper().internalAutoRefresh(result, cld);
+                    /*
+                    TODO: Improve! Find better solution
+                    */
+                    FieldDescriptor[] flds = cld.getLobFields();
+                    writeFields(getRsAndStmt(), rowReader, row, flds, result);
+                    pb.serviceLobHelper().wrapLobFields(cld, result);
                 }
                 pb.checkRefreshRelationships(result, oid, cld);
             }
@@ -532,6 +537,20 @@
     }
 
     /**
+     * Write the specified fields from result set into the target object.
+     */
+    private void writeFields(ResultSetAndStatement rs_stmt, RowReader rowReader, Map row,
FieldDescriptor[] fields, Object target)
+    {
+        rowReader.readValuesFrom(rs_stmt, row, fields);
+        FieldDescriptor fmd;
+        for (int i = 0; i < fields.length; i++)
+        {
+            fmd = fields[i];
+            fmd.getPersistentField().set(target, row.get(fmd.getColumnName()));
+        }
+    }
+
+    /**
      * Reads primary key information from current RS row and generates a
      *
      * corresponding Identity, and returns a proxy from the Identity.
@@ -1060,6 +1079,14 @@
         return m_inBatchedMode;
     }
 
+    /**
+     * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
+     */
+    public void disableLifeCycleEvents()
+    {
+        disableLifeCycleEvents = true;
+    }
+
     //***********************************************************
     // inner classes
     //***********************************************************
@@ -1159,13 +1186,5 @@
         {
             super(msg, cause);
         }
-    }
-
-    /**
-     * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
-     */
-    public void disableLifeCycleEvents()
-    {
-        disableLifeCycleEvents = true;
     }
 }



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