cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1423290 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/CayenneContext.java test/java/org/apache/cayenne/NestedCayenneContextTest.java
Date Tue, 18 Dec 2012 06:40:30 GMT
Author: aadamchik
Date: Tue Dec 18 06:40:29 2012
New Revision: 1423290

URL: http://svn.apache.org/viewvc?rev=1423290&view=rev
Log:
CAY-1714 ROP: Cayenne tries to build a query for non committed object when using more than
2 nested contexts

patch by Ilya Drabenia

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java?rev=1423290&r1=1423289&r2=1423290&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Tue Dec 18 06:40:29 2012
@@ -257,6 +257,7 @@ public class CayenneContext extends Base
         ClassDescriptor descriptor = getEntityResolver().getClassDescriptor(
                 entity.getName());
         T object = (T) descriptor.createObject();
+        descriptor.injectValueHolders(object);
         registerNewObject((Persistent) object, entity.getName(), descriptor);
         return object;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java?rev=1423290&r1=1423289&r2=1423290&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
Tue Dec 18 06:40:29 2012
@@ -33,6 +33,8 @@ import org.apache.cayenne.testdo.mt.Clie
 import org.apache.cayenne.testdo.mt.ClientMtTable2;
 import org.apache.cayenne.testdo.mt.ClientMtTooneDep;
 import org.apache.cayenne.testdo.mt.ClientMtTooneMaster;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
 import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.client.ClientCase;
@@ -695,6 +697,25 @@ public class NestedCayenneContextTest ex
         // fetching other relationship... this fails per CAY-1183
         childMt2.getTable3();
     }
+    
+    /**
+     * CAY1714
+     */
+    public void testQueriesOnTemporaryObject() throws Exception {
+        ObjectContext clientContext = runtime.getContext((DataChannel) this.clientContext);
+        ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
+
+        ObjectContext childContext = runtime.getContext((DataChannel) clientContext);
+        ClientMtTable1 childMt = (ClientMtTable1) Cayenne.objectForPK(childContext, parentMt.getObjectId());
+        childMt.setGlobalAttribute1("1183");
+        ClientMtTable2 childMt2 = childContext.newObject(ClientMtTable2.class);
+        childMt2.setGlobalAttribute("1183");
+        childMt2.setTable1(childMt);
+
+        childContext.commitChangesToParent();
+
+        assertNull(childMt2.getTable3());
+    }
 
     public void testCAY1194() throws Exception {
         ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);



Mime
View raw message