db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java
Date Tue, 08 Jul 2003 13:00:07 GMT
arminw      2003/07/08 06:00:07

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  fix posted by David Corbin:
  PB keeps a list of objects that are marked for delete, and avoids deleting
  them twice.
  Should this be based on Identity, rather than on the object (and it's
  equals method) itself?
  
  Revision  Changes    Path
  1.25      +11 -11    db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- PersistenceBrokerImpl.java	5 Jul 2003 11:08:36 -0000	1.24
  +++ PersistenceBrokerImpl.java	8 Jul 2003 13:00:06 -0000	1.25
  @@ -410,21 +410,21 @@
                * MBAIRD
                * 1. if we are marked for delete already, avoid recursing on this object
                */
  -            if (markedForDelete.contains(obj))
  +            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  +            Identity oid = new Identity(obj, this, cld);
  +            if (markedForDelete.contains(oid))
               {
                   return;
               }
  -
               /**
                * MBAIRD
                * 2. register object in markedForDelete map.
                */
  -            markedForDelete.add(obj);
  +            markedForDelete.add(oid);
               // Invoke events on PersistenceBrokerAware instances and listeners
               BEFORE_DELETE_EVENT.setTarget(obj);
               fireBrokerEvent(BEFORE_DELETE_EVENT);
   
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
               // 1. delete dependend collections
   			if (cld.getCollectionDescriptors().size() > 0)
   			{
  @@ -438,7 +438,7 @@
               	deleteReferences(obj, cld.getObjectReferenceDescriptors());
   			}
   			// remove obj from the object cache:
  -            objectCache.remove(new Identity(obj, this, cld));
  +            objectCache.remove(oid);
   
               // Invoke events on PersistenceBrokerAware instances and listeners
               AFTER_DELETE_EVENT.setTarget(obj);
  @@ -696,7 +696,7 @@
   
       /**
        * update the the foreign key fields of obj with the key fields of ref
  -     * 
  +     *
        * @param obj referencing object or proxy
        * @param ref referenced object or proxy
        * @param rds
  @@ -801,7 +801,7 @@
                   while (colIterator.hasNext())
                   {
                       Object otherObj = colIterator.next();
  -                    
  +
                       // for m:n mapped collections store association implementing entries
                       if (cds.isMtoNRelation())
                       {
  @@ -821,7 +821,7 @@
                               // BRJ: do not assign fk if not required
                               // to avoid materialization of proxy
                               assertFkAssignment(otherObj, obj, cds);
  -                        }    
  +                        }
                           storeCollectionObject(cds, otherObj);
                       }
                   }
  @@ -1257,7 +1257,7 @@
           Identity id;
   
           // BRJ: check if we have non null pk values
  -        // TBD  we should also check primitives 
  +        // TBD  we should also check primitives
           // to avoid creation of unmaterializable proxies
           for (int i = 0; i < pkVals.length; i++)
           {
  @@ -1279,7 +1279,7 @@
           id = new Identity(rds.getItemClass(), referencedClass, pkVals);
           //JMM : why not see if the object has already been loaded
           if ( objectCache.lookup(id) != null )
  -        {   
  +        {
              return getObjectByIdentity(id);
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message