cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r567407 - in /cayenne/main/trunk: framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/
Date Sun, 19 Aug 2007 14:15:55 GMT
Author: aadamchik
Date: Sun Aug 19 07:15:54 2007
New Revision: 567407

URL: http://svn.apache.org/viewvc?view=rev&rev=567407
Log:
CAY-843 Remove arbitrary reverse relationship mapping limitations 

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ChildDiffLoader.java
    cayenne/main/trunk/itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/RuntimeLoaderDelegateClientDefaultsLoadingTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ChildDiffLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ChildDiffLoader.java?view=diff&rev=567407&r1=567406&r2=567407
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ChildDiffLoader.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/ChildDiffLoader.java
Sun Aug 19 07:15:54 2007
@@ -30,6 +30,7 @@
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.Query;
+import org.apache.cayenne.reflect.ArcProperty;
 import org.apache.cayenne.reflect.AttributeProperty;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.cayenne.reflect.Property;
@@ -110,7 +111,7 @@
 
         ClassDescriptor descriptor = context.getEntityResolver().getClassDescriptor(
                 ((ObjectId) nodeId).getEntityName());
-        Property property = descriptor.getProperty(arcId.toString());
+        ArcProperty property = (ArcProperty) descriptor.getProperty(arcId.toString());
 
         property.visit(new PropertyVisitor() {
 
@@ -119,7 +120,12 @@
             }
 
             public boolean visitToMany(ToManyProperty property) {
-                property.addTarget(source, target, false);
+                // connect reverse arc if the relationship is marked as "runtime"
+                ArcProperty reverseArc = property.getComplimentaryReverseArc();
+                boolean autoConnectReverse = reverseArc != null
+                        && reverseArc.getRelationship().isRuntime();
+
+                property.addTarget(source, target, autoConnectReverse);
                 return false;
             }
 
@@ -143,8 +149,13 @@
             }
 
             public boolean visitToMany(ToManyProperty property) {
+                // connect reverse arc if the relationship is marked as "runtime"
+                ArcProperty reverseArc = property.getComplimentaryReverseArc();
+                boolean autoConnectReverse = reverseArc != null
+                        && reverseArc.getRelationship().isRuntime();
+
                 Persistent target = findObject(targetNodeId);
-                property.removeTarget(source, target, false);
+                property.removeTarget(source, target, autoConnectReverse);
                 return false;
             }
 

Modified: cayenne/main/trunk/itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/RuntimeLoaderDelegateClientDefaultsLoadingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/RuntimeLoaderDelegateClientDefaultsLoadingTest.java?view=diff&rev=567407&r1=567406&r2=567407
==============================================================================
--- cayenne/main/trunk/itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/RuntimeLoaderDelegateClientDefaultsLoadingTest.java
(original)
+++ cayenne/main/trunk/itests/cayenne-api/src/test/java/org/apache/cayenne/itest/cpa/conf/RuntimeLoaderDelegateClientDefaultsLoadingTest.java
Sun Aug 19 07:15:54 2007
@@ -59,8 +59,7 @@
 		o2 = (DefaultsTable3) DataObjectUtils.objectForPK(clientContext,
 				DefaultsTable3.class, Collections.singletonMap("id", 2));
 
-		// TODO: andrus 8/15/2007 this fails
-		// assertEquals(1, o2.getDefaultTable4s().size());
-		// assertEquals(0, o1.getDefaultTable4s().size());
+		assertEquals(1, o2.getDefaultTable4s().size());
+		assertEquals(0, o1.getDefaultTable4s().size());
 	}
 }



Mime
View raw message