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

From: Mike Kienenberger (JIRA) ("Mike)
Date: Fri Jul 28 2006 - 13:49:49 EDT

  • Next message: Mike Kienenberger: "Re: Deleted objects showing up a serialized data context"

    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
    



    This archive was generated by hypermail 2.0.0 : Fri Jul 28 2006 - 13:52:16 EDT