cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1423292 - in /cayenne/main/branches/STABLE-3.1/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:51:17 GMT
Author: aadamchik
Date: Tue Dec 18 06:51:16 2012
New Revision: 1423292

URL: http://svn.apache.org/viewvc?rev=1423292&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
patch by Dzmitry Kazimirchyk

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

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java?rev=1423292&r1=1423291&r2=1423292&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/CayenneContext.java
Tue Dec 18 06:51:16 2012
@@ -259,6 +259,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/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java?rev=1423292&r1=1423291&r2=1423292&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/NestedCayenneContextTest.java
Tue Dec 18 06:51:16 2012
@@ -32,6 +32,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;
@@ -691,6 +693,26 @@ public class NestedCayenneContextTest ex
         // fetching other relationship... this fails per CAY-1183
         childMt2.getTable3();
     }
+    
+    /**
+     * CAY1714
+     */
+    public void testQueriesOnTemporaryObject() throws Exception {
+        ObjectContext clientContext = this.clientContext.createChildContext();
+        ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);
+
+        ObjectContext child = clientContext.createChildContext();
+        ClientMtTable1 childMt = (ClientMtTable1) Cayenne.objectForPK(child, parentMt.getObjectId());
+        childMt.setGlobalAttribute1("1183");
+        ClientMtTable2 childMt2 = child.newObject(ClientMtTable2.class);
+        childMt2.setGlobalAttribute("1183");
+        childMt2.setTable1(childMt);
+
+        child.commitChangesToParent();
+
+        // this will fail
+        childMt2.getTable3();
+    }
 
     public void testCAY1194() throws Exception {
         ClientMtTable1 parentMt = clientContext.newObject(ClientMtTable1.class);



Mime
View raw message