db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer CollectionPrefetcher.java
Date Sat, 06 Mar 2004 22:38:52 GMT
olegnitz    2004/03/06 14:38:52

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        CollectionPrefetcher.java
  Log:
  Possible NPE fixed
  
  Revision  Changes    Path
  1.23      +11 -8     db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
  
  Index: CollectionPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- CollectionPrefetcher.java	15 Jan 2004 20:58:46 -0000	1.22
  +++ CollectionPrefetcher.java	6 Mar 2004 22:38:52 -0000	1.23
  @@ -160,13 +160,13 @@
   
       /**
        * associate the batched Children with their owner object loop over children
  -     */   
  +     */
       protected void associateBatched(Collection owners, Collection children)
       {
           CollectionDescriptor cds = getCollectionDescriptor();
           PersistentField field = cds.getPersistentField();
           PersistenceBroker pb = getBroker();
  -        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
       
  +        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
           Class collectionClass = cds.getCollectionClass(); // this collection type will
be used:
           HashMap ownerIdsToLists = new HashMap();
   
  @@ -176,28 +176,31 @@
               Object owner = it.next();
               ownerIdsToLists.put(new Identity(owner,pb), new ArrayList());
           }
  -        
  +
           // build the children lists for the owners
           for (Iterator it = children.iterator(); it.hasNext();)
           {
               Object child = it.next();
               // BRJ: use cld for real class, relatedObject could be Proxy
               ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(ProxyHelper.getRealClass(child));
  -            
  +
               Object[] fkValues = cds.getForeignKeyValues(child, cld);
               Identity ownerId = new Identity(null, ownerTopLevelClass, fkValues);
               List list = (List) ownerIdsToLists.get(ownerId);
  -            list.add(child);
  +            if (list != null)
  +            {
  +                list.add(child);
  +            }
           }
   
  -        // connect children list to owners  
  +        // connect children list to owners
           for (Iterator it = owners.iterator(); it.hasNext();)
           {
               Object result;
               Object owner = it.next();
               Identity ownerId = new Identity(owner, pb);
               List list = (List) ownerIdsToLists.get(ownerId);
  -                       
  +
               if ((collectionClass == null) && field.getType().isArray())
               {
                   int length = list.size();
  
  
  

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