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 Sat, 20 Dec 2003 21:01:09 GMT
brj         2003/12/20 13:01:09

  Modified:    src/java/org/apache/ojb/broker/core Tag: OJB_BRANCH_1_0
                        PersistenceBrokerImpl.java
  Log:
  fixed bug in m:n relationship using Array
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.60.2.2  +22 -30    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.60.2.1
  retrieving revision 1.60.2.2
  diff -u -r1.60.2.1 -r1.60.2.2
  --- PersistenceBrokerImpl.java	19 Dec 2003 17:38:13 -0000	1.60.2.1
  +++ PersistenceBrokerImpl.java	20 Dec 2003 21:01:09 -0000	1.60.2.2
  @@ -55,6 +55,7 @@
    */
   
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Collection;
   import java.util.Collections;
   import java.util.Enumeration;
  @@ -816,7 +817,15 @@
                       else
                       {
                           currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj);
  -                        mtoNBroker.deleteMtoNImplementor(cds, obj, (Collection)col, currentMtoNKeys);
  +                        
  +                        if (col.getClass().isArray())
  +                        {
  +                            mtoNBroker.deleteMtoNImplementor(cds, obj, Arrays.asList((Object[])col),
currentMtoNKeys);
  +                        }
  +                        else
  +                        {
  +                            mtoNBroker.deleteMtoNImplementor(cds, obj, (Collection)col,
currentMtoNKeys);
  +                        }
                       }
                   }
   
  @@ -849,15 +858,21 @@
                       // for m:n mapped collections store association implementing entries
                       if (cds.isMtoNRelation())
                       {
  -                        // 1. Store depended upon object first to avoid FK violation
  -                        storeCollectionObject(cds, otherObj);
  +                        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);
                       }
  -                    // for 1:n mapped collection assert proper fk assignment
                       else
                       {
                           if (cds.getCascadeStore())
  @@ -865,8 +880,8 @@
                               // BRJ: do not assign fk if not required
                               // to avoid materialization of proxy
                               assertFkAssignment(otherObj, obj, cds);
  +                            store(otherObj);
                           }
  -                        storeCollectionObject(cds, otherObj);
                       }
                   }
   
  @@ -878,30 +893,7 @@
               }
           }
       }
  -
  -    /**
  -     * Store an object which is a part of a collection of another object (Via CollectionDescriptors)
  -     * <b>otherObject</b> will be stored if auto-update is true
  -     *
  -     * @param otherObject Object which is contained into other's object collection
  -     * @param cds CollectionDescriptor providing metadata about the collection in which
<b>otherObject</b> is part of
  -     * @throws PersistenceBrokerException if some goes wrong - please see the error message
for details
  -     */
  -    private void storeCollectionObject(CollectionDescriptor cds, Object otherObject)
  -    {
  -        // if cascade store: store associated object
  -        if (cds.getCascadeStore())
  -        {
  -            store(otherObject);
  -        }
  -        else
  -        {
  -            if(logger.isEnabledFor(Logger.INFO)) logger.info("Cascade store for this collection-descriptor
(" + cds.getAttributeName()
  -                    + ") was set to false.");
  -        }
  -
  -    }
  -
  +    
       /**
        * retrieve all References (also Collection-attributes) of a given instance.
        * Loading is forced, even if the collection- and reference-descriptors differ.
  
  
  

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