cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r551302 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
Date Wed, 27 Jun 2007 19:58:14 GMT
Author: aadamchik
Date: Wed Jun 27 12:58:13 2007
New Revision: 551302

URL: http://svn.apache.org/viewvc?view=rev&rev=551302
Log:
fixing a 3.0-only bug that disabled correct commit sorting of objects with reflexive relationships

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java?view=diff&rev=551302&r1=551301&r2=551302
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/map/AshwoodEntitySorter.java
Wed Jun 27 12:58:13 2007
@@ -29,11 +29,11 @@
 import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.Persistent;
+import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.commons.collections.comparators.ReverseComparator;
@@ -300,12 +300,19 @@
         DbRelationship finalRel = (DbRelationship) toOneRel.getDbRelationships().get(0);
         ObjectContext context = object.getObjectContext();
 
-        // find snapshot
+        // find committed snapshot - so we can't fetch from the context as it will return
+        // dirty snapshot; must go down the stack instead
         ObjectIdQuery query = new ObjectIdQuery(
                 object.getObjectId(),
                 true,
                 ObjectIdQuery.CACHE);
-        DataRow snapshot = (DataRow) DataObjectUtils.objectForQuery(context, query);
+        QueryResponse response = context.getChannel().onQuery(null, query);
+        List result = response.firstList();
+        if(result == null || result.size() == 0) {
+            return null;
+        }
+        
+        DataRow snapshot = (DataRow) result.get(0);
 
         ObjectId id = snapshot.createTargetObjectId(targetEntityName, finalRel);
         return (id != null) ? context.localObject(id, null) : null;



Mime
View raw message