cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1103307 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query: BaseQueryMetadata.java PrefetchTreeNode.java
Date Sun, 15 May 2011 10:00:04 GMT
Author: aadamchik
Date: Sun May 15 10:00:04 2011
New Revision: 1103307

URL: http://svn.apache.org/viewvc?rev=1103307&view=rev
Log:
stop using serialization for cloning inside Cayenne stack - it some class locks that kill
runtime concurrency

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/PrefetchTreeNode.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java?rev=1103307&r1=1103306&r2=1103307&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
Sun May 15 10:00:04 2011
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
@@ -34,7 +33,6 @@ import org.apache.cayenne.map.EntityReso
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.reflect.ClassDescriptor;
-import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
 import org.apache.cayenne.util.XMLSerializable;
 
@@ -102,7 +100,7 @@ class BaseQueryMetadata implements Query
                 if (root instanceof Class<?>) {
                     entity = resolver.lookupObjEntity((Class<?>) root);
                     if (entity == null) { // entity not found, try to resolve it with
-                                          // client resolver
+                        // client resolver
                         EntityResolver clientResolver = resolver
                                 .getClientEntityResolver();
                         if (clientResolver != resolver) {
@@ -325,22 +323,22 @@ class BaseQueryMetadata implements Query
     }
 
     void setPrefetchTree(PrefetchTreeNode prefetchTree) {
-        if (prefetchTree != null) {
-            // important: make a clone to allow modification independent from the
-            // caller...
-            try {
-                prefetchTree = (PrefetchTreeNode) Util
-                        .cloneViaSerialization(prefetchTree);
-            }
-            catch (CayenneRuntimeException e) {
-                throw e;
-            }
-            catch (Exception e) {
-                throw new CayenneRuntimeException("Error cloning prefetch tree", e);
-            }
+        this.prefetchTree = prefetchTree != null ? deepClone(prefetchTree, null) : null;
+    }
+
+    private PrefetchTreeNode deepClone(PrefetchTreeNode source, PrefetchTreeNode targetParent)
{
+
+        PrefetchTreeNode target = new PrefetchTreeNode(targetParent, source.getName());
+        target.setEjbqlPathEntityId(source.getEjbqlPathEntityId());
+        target.setEntityName(source.getEntityName());
+        target.setPhantom(source.isPhantom());
+        target.setSemantics(source.getSemantics());
+
+        for (PrefetchTreeNode child : source.getChildren()) {
+            target.addChild(deepClone(child, target));
         }
 
-        this.prefetchTree = prefetchTree;
+        return target;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/PrefetchTreeNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/PrefetchTreeNode.java?rev=1103307&r1=1103306&r2=1103307&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/PrefetchTreeNode.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/PrefetchTreeNode.java
Sun May 15 10:00:04 2011
@@ -69,9 +69,9 @@ public class PrefetchTreeNode implements
      * Creates a phantom PrefetchTreeNode, initializing it with parent node and a name of
      * a relationship segment connecting this node with the parent.
      */
-    protected PrefetchTreeNode(PrefetchTreeNode parent, String segmentPath) {
+    protected PrefetchTreeNode(PrefetchTreeNode parent, String name) {
         this.parent = parent;
-        this.name = segmentPath;
+        this.name = name;
         this.phantom = true;
         this.semantics = UNDEFINED_SEMANTICS;
     }



Mime
View raw message