cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r420169 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src: cayenne/java/org/objectstyle/cayenne/access/ tests/java/org/objectstyle/cayenne/access/
Date Sat, 08 Jul 2006 17:31:39 GMT
Author: aadamchik
Date: Sat Jul  8 10:31:38 2006
New Revision: 420169

URL: http://svn.apache.org/viewvc?rev=420169&view=rev
Log:
CAY-592

Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowUtils.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectResolver.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/InheritanceTst.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowUtils.java?rev=420169&r1=420168&r2=420169&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowUtils.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/DataRowUtils.java
Sat Jul  8 10:31:38 2006
@@ -249,7 +249,24 @@
                         || !diff.containsArcSnapshot(rel.getName())
                         || !Util.nullSafeEquals(id, diff.getArcSnapshotValue(rel
                                 .getName()))) {
-                    Object target = (id != null) ? context.localObject(id, null) : null;
+
+                    Object target;
+                    if (id == null) {
+                        target = null;
+                    }
+                    else {
+                        // if inheritance is involved, we can't use 'localObject' .. must
+                        // turn to fault instead
+                        ObjEntity targetEntity = (ObjEntity) rel.getTargetEntity();
+                        if (context.getEntityResolver().lookupInheritanceTree(
+                                targetEntity) != null) {
+                            target = Fault.getToOneFault();
+                        }
+                        else {
+                            target = context.localObject(id, null);
+                        }
+                    }
+
                     object.writeProperty(rel.getName(), target);
                 }
             }

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectResolver.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectResolver.java?rev=420169&r1=420168&r2=420169&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectResolver.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ObjectResolver.java
Sat Jul  8 10:31:38 2006
@@ -247,6 +247,12 @@
                     break;
                 }
             case PersistenceState.HOLLOW:
+                if(!refreshObjects) {
+                    DataRow cachedRow = cache.getCachedSnapshot(anId);
+                    if(cachedRow != null) {
+                        row = cachedRow;
+                    }
+                }
                 DataRowUtils.mergeObjectWithSnapshot(objectEntity, object, row);
                 object.setSnapshotVersion(row.getVersion());
             default:

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/InheritanceTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/InheritanceTst.java?rev=420169&r1=420168&r2=420169&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/InheritanceTst.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/access/InheritanceTst.java
Sat Jul  8 10:31:38 2006
@@ -58,6 +58,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.objectstyle.cayenne.DataObjectUtils;
 import org.objectstyle.cayenne.query.SelectQuery;
 import org.objectstyle.cayenne.testdo.inherit.AbstractPerson;
 import org.objectstyle.cayenne.testdo.inherit.Address;
@@ -130,7 +131,28 @@
 
         assertEquals(1, addresses.size());
         Address address = (Address) addresses.get(0);
-        assertSame(Manager.class, address.getToEmployee().getClass());
+        Employee e = address.getToEmployee();
+        
+        assertSame(Manager.class, e.getClass());
+    }
+    
+    public void testCAY592() throws Exception {
+        createTestData("testManagerAddress");
+        List addresses = context.performQuery(new SelectQuery(Address.class));
+
+        assertEquals(1, addresses.size());
+        Address address = (Address) addresses.get(0);
+        Employee e = address.getToEmployee();
+
+        // CAY-592 - make sure modification of the address in a parallel context 
+        // doesn't mess up the Manager
+        DataContext c2 = context.getParentDataDomain().createDataContext();
+        e = (Employee) DataObjectUtils.objectForPK(c2, e.getObjectId());
+        address = (Address) e.getAddresses().get(0);
+  
+        assertSame(e, address.getToEmployee());
+        address.setCity("XYZ");
+        assertSame(e, address.getToEmployee());
     }
 
     /**



Mime
View raw message