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/accesslayer MtoNCollectionPrefetcher.java
Date Fri, 26 Mar 2004 21:02:39 GMT
brj         2004/03/26 13:02:38

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        MtoNCollectionPrefetcher.java
  Log:
  first attempt to fix problem with multiple keys
  
  Revision  Changes    Path
  1.8       +18 -3     db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java
  
  Index: MtoNCollectionPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MtoNCollectionPrefetcher.java	11 Mar 2004 18:16:06 -0000	1.7
  +++ MtoNCollectionPrefetcher.java	26 Mar 2004 21:02:38 -0000	1.8
  @@ -315,8 +315,14 @@
               FieldDescriptor[] itemPkFields)
       {
           Criteria crit = new Criteria();
  +        Criteria critValue = new Criteria();
           Iterator iter = ids.iterator();
   
  +        for (int i = 0; i < itemPkFields.length; i++)
  +        {
  +            crit.addEqualToColumn(itemPkFields[i].getAttributeName(), itemFkCols[i]);
  +        }
  +        
           while (iter.hasNext())
           {
               Criteria c = new Criteria();
  @@ -335,16 +341,24 @@
                       c.addColumnEqualTo(fkCols[i], val[i]);
                   }
   
  -                crit.addEqualToColumn(itemPkFields[i].getAttributeName(), itemFkCols[i]);
               }
  -            crit.addOrCriteria(c);
  +          
  +            critValue.addOrCriteria(c);
           }
   
  +        crit.addAndCriteria(critValue);
           return crit;
       }
   
       /**
        * associate the batched Children with their owner object loop over children
  +     * <br><br>
  +     * BRJ: There is a potential problem with the type of the pks used to build the Identities.
  +     * When creating an Identity for the owner, the type of pk is defined by the instvars

  +     * representing the pk. When creating the Identity based on the mToNImplementor the
  +     * type of the pk is defined by the jdbc-type of field-descriptor of the referenced
class.
  +     * This type mismatch results in Identities not being equal. <br>
  +     * Integer[] {10,20,30} is not equal Long[] {10,20,30}
        */
       protected void associateBatched(Collection owners, Collection children, Collection
mToNImplementors)
       {
  @@ -386,6 +400,7 @@
               Identity ownerId = new Identity(null, ownerTopLevelClass, ownerPk);
               Identity childId = new Identity(null, childTopLevelClass, childPk);
   
  +            // Identities may not be equal due to type-mismatch
               Collection list = (Collection) ownerIdsToLists.get(ownerId);
               Object child = childMap.get(childId);
               list.add(child);
  
  
  

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