openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r650684 - /openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
Date Tue, 22 Apr 2008 22:46:06 GMT
Author: pcl
Date: Tue Apr 22 15:45:49 2008
New Revision: 650684

URL: http://svn.apache.org/viewvc?rev=650684&view=rev
Log:
OPENJPA-576. Committing on behalf of Sandeep Shrivastava.

Modified:
    openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java

Modified: openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java?rev=650684&r1=650683&r2=650684&view=diff
==============================================================================
--- openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
(original)
+++ openjpa/branches/1.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
Tue Apr 22 15:45:49 2008
@@ -410,14 +410,13 @@
         //### we selected the embedded object fields and load the object
         //### immediately; this will be inefficient when the embedded object
         //### was not selected after all
-
         StoreContext ctx = store.getContext();
         OpenJPAStateManager em = ctx.embed(null, null, sm, field);
         sm.storeObject(field.getIndex(), em.getManagedInstance());
 
         FieldMapping[] fields = field.getEmbeddedMapping().getFieldMappings();
         Object eres, processed;
-        boolean loaded = false;
+        boolean needsLoad = false;
         for (int i = 0; i < fields.length; i++) {
             eres = res.getEager(fields[i]);
             res.startDataRequest(fields[i]);
@@ -429,18 +428,24 @@
                         fields[i].loadEagerParallel(em, store, fetch, eres);
                     if (processed != eres)
                         res.putEager(fields[i], processed);
-                } else
+                } else {
                     fields[i].load(em, store, fetch, res);
-                loaded |= em.getLoaded().get(i);
+                }
+                needsLoad = needsLoad || (!em.getLoaded().get(i) && 
+                    fetch.requiresFetch(fields[i])
+                        == FetchConfiguration.FETCH_LOAD);
             } finally {
                 res.endDataRequest();
             }
         }
 
-        // after loading everything from result, load the rest of the
-        // configured fields
-        if (loaded)
-            em.load(fetch);
+        // After loading everything from result, load the rest of the
+        // configured fields if anything is missing.
+        if (needsLoad && 
+            fetch.requiresFetch(field.getFieldMetaData()) == 
+                JDBCFetchConfiguration.FETCH_LOAD) {
+          em.load(fetch);
+        }
     }
 
     /**



Mime
View raw message