cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r812304 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/
Date Mon, 07 Sep 2009 23:47:02 GMT
Author: aadamchik
Date: Mon Sep  7 23:47:01 2009
New Revision: 812304

URL: http://svn.apache.org/viewvc?rev=812304&view=rev
Log:
CAY-1250 Prefetching doesn't work with prefetched subentity

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/StackLookupParentAttachmentStrategy.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolverNode.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachementStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorTreeBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolver.java
Mon Sep  7 23:47:01 2009
@@ -224,10 +224,10 @@
             // find existing object, if found skip further processing
             Map id = processorNode.idFromFlatRow(currentFlatRow);
             object = processorNode.getResolved(id);
-
+            DataRow row = null;
             if (object == null) {
 
-                DataRow row = processorNode.rowFromFlatRow(currentFlatRow);
+                row = processorNode.rowFromFlatRow(currentFlatRow);
                 object = processorNode.getResolver().objectFromDataRow(row);
 
                 // LEFT OUTER JOIN produced no matches...
@@ -241,11 +241,8 @@
 
             // linking by parent needed even if an object is already there
             // (many-to-many case)
-            if (processorNode.isPartitionedByParent()) {
-                PrefetchProcessorNode parent = (PrefetchProcessorNode) processorNode
-                        .getParent();
-                processorNode.linkToParent(object, parent.getLastResolved());
-            }
+
+            processorNode.getParentAttachmentStrategy().linkToParent(row, object);
 
             processorNode.setLastResolved(object);
             return processorNode.isJointChildren();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolverNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolverNode.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolverNode.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/HierarchicalObjectResolverNode.java
Mon Sep  7 23:47:01 2009
@@ -31,25 +31,12 @@
 
 class HierarchicalObjectResolverNode extends ObjectResolver {
 
-    private ParentAttachmentStrategy parentAttachmentStrategy;
+    private PrefetchProcessorNode node;
 
     HierarchicalObjectResolverNode(PrefetchProcessorNode node, DataContext context,
             ClassDescriptor descriptor, boolean refresh) {
         super(context, descriptor, refresh);
-
-        if (node.getParent() == null || node.getParent().isPhantom()) {
-            this.parentAttachmentStrategy = new NoopParentAttachmentStrategy();
-        }
-        else if (node
-                .getIncoming()
-                .getRelationship()
-                .isSourceIndependentFromTargetChange()) {
-            this.parentAttachmentStrategy = new JoinedIdParentAttachementStrategy(context
-                    .getGraphManager(), node);
-        }
-        else {
-            this.parentAttachmentStrategy = new ResultScanParentAttachmentStrategy(node);
-        }
+        this.node = node;
     }
 
     @Override
@@ -94,7 +81,7 @@
             // joint prefetch...
             results.add(object);
 
-            parentAttachmentStrategy.linkToParent(row, object);
+            node.getParentAttachmentStrategy().linkToParent(row, object);
         }
 
         // now deal with snapshots

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachementStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachementStrategy.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachementStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/JoinedIdParentAttachementStrategy.java
Mon Sep  7 23:47:01 2009
@@ -90,10 +90,6 @@
             }
         }
 
-        // don't attach to hollow objects
-        if (parentObject != null
-                && parentObject.getPersistenceState() != PersistenceState.HOLLOW)
{
-            node.linkToParent(object, parentObject);
-        }
+        node.linkToParent(object, parentObject);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
Mon Sep  7 23:47:01 2009
@@ -27,6 +27,7 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.Fault;
+import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.ValueHolder;
 import org.apache.cayenne.query.PrefetchTreeNode;
@@ -50,7 +51,8 @@
     Map partitionByParent;
     boolean jointChildren;
 
-    Persistent lastResolved;
+    private Persistent lastResolved;
+    private ParentAttachmentStrategy parentAttachmentStrategy;
 
     PrefetchProcessorNode(PrefetchProcessorNode parent, String segmentPath) {
         super(parent, segmentPath);
@@ -73,7 +75,7 @@
      * 'connectToParents'.
      */
     void linkToParent(Persistent object, Persistent parent) {
-        if (parent != null) {
+        if (parent != null && parent.getPersistenceState() != PersistenceState.HOLLOW)
{
 
             // if a relationship is to-one (i.e. flattened to-one), can connect right
             // away.... write directly to prevent changing persistence state.
@@ -237,4 +239,12 @@
                 "phantom",
                 phantom).toString();
     }
+
+    ParentAttachmentStrategy getParentAttachmentStrategy() {
+        return parentAttachmentStrategy;
+    }
+
+    void setParentAttachmentStrategy(ParentAttachmentStrategy parentAttachmentStrategy) {
+        this.parentAttachmentStrategy = parentAttachmentStrategy;
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorTreeBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorTreeBuilder.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorTreeBuilder.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorTreeBuilder.java
Mon Sep  7 23:47:01 2009
@@ -154,7 +154,7 @@
         node.setDataRows(rows);
 
         node.setIncoming(arc);
-        if (node.getParent() != null) {
+        if (node.getParent() != null && !node.isJointPrefetch()) {
             node.setResolver(new HierarchicalObjectResolverNode(
                     node,
                     context,
@@ -166,6 +166,28 @@
                     .isRefreshingObjects()));
         }
 
+        if (node.getParent() == null || node.getParent().isPhantom()) {
+            node.setParentAttachmentStrategy(new NoopParentAttachmentStrategy());
+        }
+        else if (node.isJointPrefetch()) {
+            node
+                    .setParentAttachmentStrategy(new StackLookupParentAttachmentStrategy(
+                            node));
+        }
+        else if (node
+                .getIncoming()
+                .getRelationship()
+                .isSourceIndependentFromTargetChange()) {
+            node.setParentAttachmentStrategy(new JoinedIdParentAttachementStrategy(
+                    context.getGraphManager(),
+                    node));
+        }
+        else {
+            node
+                    .setParentAttachmentStrategy(new ResultScanParentAttachmentStrategy(
+                            node));
+        }
+
         if (currentNode != null) {
             currentNode.addChild(node);
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java?rev=812304&r1=812303&r2=812304&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
Mon Sep  7 23:47:01 2009
@@ -131,5 +131,4 @@
             parents.add(objects.get(i));
         }
     }
-
 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/StackLookupParentAttachmentStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/StackLookupParentAttachmentStrategy.java?rev=812304&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/StackLookupParentAttachmentStrategy.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/StackLookupParentAttachmentStrategy.java
Mon Sep  7 23:47:01 2009
@@ -0,0 +1,36 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ ****************************************************************/
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.Persistent;
+
+class StackLookupParentAttachmentStrategy implements ParentAttachmentStrategy {
+
+    private PrefetchProcessorNode node;
+
+    StackLookupParentAttachmentStrategy(PrefetchProcessorNode node) {
+        this.node = node;
+    }
+
+    public void linkToParent(DataRow row, Persistent object) {
+        PrefetchProcessorNode parent = (PrefetchProcessorNode) node.getParent();
+        node.linkToParent(object, parent.getLastResolved());
+    }
+}



Mime
View raw message