You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by "Mike Kienenberger (JIRA)" <ji...@apache.org> on 2006/07/28 19:49:49 UTC

[JIRA] Created: (CAY-614) ToManyList contains references to transient objects

ToManyList contains references to transient objects
---------------------------------------------------

         Key: CAY-614
         URL: http://issues.apache.org/cayenne/browse/CAY-614
     Project: Cayenne
        Type: Bug

  Components: Cayenne Core Library  
    Versions: 1.2 [STABLE]    
    Reporter: Mike Kienenberger
 Assigned to: Mike Kienenberger 


ToManyList can contain references to temporary objects, which causes transient objects to be serialized with the DataContext.

The fix is to not add NEW or TRANSIENT objects to the removedFromUnresolved list.   These objects will never be removed from a database fetch list as they don't exist in the database, so there's no point in keeping a reference to them.

   boolean removeLocal(Object object) {
       if (addedToUnresolved != null) {
           addedToUnresolved.remove(object);
       }

       if (removedFromUnresolved == null) {
           removedFromUnresolved = new LinkedList();
       }

       // 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;
   }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/cayenne/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira