cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mkien...@apache.org
Subject svn commit: r431970 - /incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java
Date Wed, 16 Aug 2006 18:13:25 GMT
Author: mkienenb
Date: Wed Aug 16 11:13:24 2006
New Revision: 431970

URL: http://svn.apache.org/viewvc?rev=431970&view=rev
Log:
Fix for CAY-614 -- ToManyList contains references to transient objects.

Modified:
    incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java

Modified: incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java?rev=431970&r1=431969&r2=431970&view=diff
==============================================================================
--- incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java
(original)
+++ incubator/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/ToManyList.java
Wed Aug 16 11:13:24 2006
@@ -423,10 +423,26 @@
             removedFromUnresolved = new LinkedList();
         }
 
-        removedFromUnresolved.addLast(object);
+        // No point in adding a new or transient object -- these will never be fetched from
the database.
+        boolean shouldAddToRemovedFromUnresolvedList = true;
+        if (object instanceof DataObject) {
+            DataObject dataObject = (DataObject) object;
+            if ( (dataObject.getPersistenceState() == PersistenceState.TRANSIENT)
+              || (dataObject.getPersistenceState() == PersistenceState.NEW) ) {
+                shouldAddToRemovedFromUnresolvedList = false;
+            }
+        }
+
+        if (shouldAddToRemovedFromUnresolvedList) {
+            removedFromUnresolved.addLast(object);
+        }
 
         // this is really meaningless, since we don't know
         // if an object was present in the list
         return true;
+    }
+    
+    public String toString() {
+        return getClass().getName() + "@" + System.identityHashCode(this);
     }
 }



Mime
View raw message