db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java
Date Sun, 29 Feb 2004 09:34:53 GMT
brj         2004/02/29 01:34:53

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  refactoring of storeCollections
  
  Revision  Changes    Path
  1.72      +46 -36    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.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- PersistenceBrokerImpl.java	28 Feb 2004 21:42:33 -0000	1.71
  +++ PersistenceBrokerImpl.java	29 Feb 2004 09:34:53 -0000	1.72
  @@ -901,41 +901,7 @@
                   Iterator colIterator = getCollectionIterator(cds, col);
                   while (colIterator.hasNext())
                   {
  -                    Object otherObj = colIterator.next();
  -
  -                    // for m:n mapped collections store association implementing entries
  -                    if (cds.isMtoNRelation())
  -                    {
  -                        if (cds.getCascadeStore())
  -                        {
  -                            // 1. Store depended upon object first to avoid FK violation
  -                            store(otherObj);
  -
  -                            // BRJ: store could have inserted MtoNImplementors
  -                            // so we need to read them to avoid ref. integrity
  -                            // violations
  -                            currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj);
  -                        }
  -                        // 2. Store indirection record
  -                        // BRJ: this could cause integrity problems because
  -                        // obj may not be stored depending on auto-update
  -                        mtoNBroker.storeMtoNImplementor(cds, obj, otherObj, currentMtoNKeys);
  -                    }
  -                    else
  -                    {
  -                        // BRJ: do not assign fk if not required
  -                        // to avoid materialization of proxy
  -                        // olegnitz: but assign if it is not proxy or is materialized
  -                        if (cds.getCascadeStore()
  -                                || ProxyHelper.isMaterialized(otherObj))
  -                        {
  -                            assertFkAssignment(otherObj, obj, cds, insert);
  -                        }
  -                        if (cds.getCascadeStore())
  -                        {
  -                            store(otherObj);
  -                        }
  -                    }
  +                     storeCollectionObject(obj, insert, cds, currentMtoNKeys, colIterator.next());
                   }
   
                   // invoke callback on collection
  @@ -947,6 +913,50 @@
           }
       }
   
  +    /**
  +     * Store an Object belonging to the collection defined by cds
  +     * @param obj the owner object
  +     * @param insert
  +     * @param cds the collection descriptor
  +     * @param currentMtoNKeys
  +     * @param otherObj the object to be stored
  +     */
  +    private void storeCollectionObject(Object obj, boolean insert, CollectionDescriptor
cds, Collection currentMtoNKeys, Object otherObj)
  +    {
  +        // for m:n mapped collections store association implementing entries
  +        if (cds.isMtoNRelation())
  +        {
  +            if (cds.getCascadeStore())
  +            {
  +                // 1. Store depended upon object first to avoid FK violation
  +                store(otherObj);
  +
  +                // BRJ: store could have inserted MtoNImplementors
  +                // so we need to read them to avoid ref. integrity
  +                // violations
  +                currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj);
  +            }
  +            // 2. Store indirection record
  +            // BRJ: this could cause integrity problems because
  +            // obj may not be stored depending on auto-update
  +            mtoNBroker.storeMtoNImplementor(cds, obj, otherObj, currentMtoNKeys);
  +        }
  +        else
  +        {
  +            // BRJ: do not assign fk if not required
  +            // to avoid materialization of proxy
  +            // olegnitz: but assign if it is not proxy or is materialized
  +            if (cds.getCascadeStore() || ProxyHelper.isMaterialized(otherObj))
  +            {
  +                assertFkAssignment(otherObj, obj, cds, insert);
  +            }
  +
  +            if (cds.getCascadeStore())
  +            {
  +                store(otherObj);
  +            }
  +        }
  +    }
   
       /**
        * Answer the Iterator for Collection or Array
  
  
  

---------------------------------------------------------------------
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