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 CollectionPrefetcher.java
Date Thu, 06 Mar 2003 08:42:53 GMT
brj         2003/03/06 00:42:53

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        CollectionPrefetcher.java
  Log:
  issue a warning when prefetching a proxied collection
  
  Revision  Changes    Path
  1.11      +16 -5     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CollectionPrefetcher.java	6 Mar 2003 08:25:49 -0000	1.10
  +++ CollectionPrefetcher.java	6 Mar 2003 08:42:53 -0000	1.11
  @@ -97,7 +97,7 @@
        */
       protected Query buildPrefetchQuery(Collection owners)
       {
  -        CollectionDescriptor cds = (CollectionDescriptor) getObjectReferenceDescriptor();
  +        CollectionDescriptor cds = getCollectionDescriptor();
           FieldDescriptor fkFields[] = cds.getForeignKeyFieldDescriptors(getItemClassDescriptor());
           Criteria crit;
   
  @@ -232,7 +232,7 @@
               }
               else
               {
  -                getLogger().error("prefetch works with Collections only");
  +                getLogger().error("Prefetch works with Collections only");
               }
           }
       }
  @@ -242,13 +242,24 @@
        */
       public void prefetchRelationship(Collection owners)
       {
  -        if (getObjectReferenceDescriptor().getPersistentField().getType().isArray())
  +        PersistentField f = getObjectReferenceDescriptor().getPersistentField();
  +        
  +        if (f.getType().isArray())
           {
  -            throw new PersistenceBrokerException("Prefetch does not yet work with Arrays");
  +            throw new PersistenceBrokerException("Prefetch does not yet work with Arrays:
'" + f.getName() + "'");
  +        }
  +        if (getCollectionDescriptor().isLazy())
  +        {
  +            getLogger().warn("Prefetching a proxied collection does not make sense: '"
+ f.getName() + "'");
           }
           else
           {
               super.prefetchRelationship(owners);
           }
  +    }
  +    
  +    protected CollectionDescriptor getCollectionDescriptor()
  +    {
  +        return (CollectionDescriptor)getObjectReferenceDescriptor();
       }
   }
  
  
  

Mime
View raw message