db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core QueryReferenceBroker.java
Date Tue, 15 Mar 2005 06:27:55 GMT
mkalen      2005/03/14 22:27:55

  Modified:    src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
                        QueryReferenceBroker.java
  Log:
  Patch by Vadim Gritsenko: assert that classToPrefetch is always restored in a finally clause
after temporary modification.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.17.2.6  +33 -20    db-ojb/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java
  
  Index: QueryReferenceBroker.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/QueryReferenceBroker.java,v
  retrieving revision 1.17.2.5
  retrieving revision 1.17.2.6
  diff -u -r1.17.2.5 -r1.17.2.6
  --- QueryReferenceBroker.java	13 Mar 2005 03:53:30 -0000	1.17.2.5
  +++ QueryReferenceBroker.java	15 Mar 2005 06:27:55 -0000	1.17.2.6
  @@ -93,10 +93,10 @@
           ClassDescriptor cld = pb.getClassDescriptor(itemClass);
           ManageableCollection result = null;
           OJBIterator iter = null;
  -        boolean isRetrievalTasksCreated = (batchRetrieval && (m_retrievalTasks
== null));
           int fullSize = -1;
           int size = 0;
   
  +        final boolean isRetrievalTasksCreated = batchRetrieval && m_retrievalTasks
== null;
           if (isRetrievalTasksCreated)
           {
               // Maps ReferenceDescriptors to HashSets of owners
  @@ -159,15 +159,21 @@
                   }
               }
   
  -
               if (isRetrievalTasksCreated)
               {
                   // turn off auto prefetching for related proxies
  -                Class saveClassToPrefetch = classToPrefetch;
  +                final Class saveClassToPrefetch = classToPrefetch;
                   classToPrefetch = null;
  -                performRetrievalTasks();
  -                classToPrefetch = saveClassToPrefetch;
  +                try
  +                {
  +                    performRetrievalTasks();
  +                }
  +                finally
  +                {
  +                    classToPrefetch = saveClassToPrefetch;
  +                }
               }
  +
               // ==> disable materialization cache
               pb.getInternalCache().disableMaterializationCache();
           }
  @@ -427,16 +433,17 @@
       public void retrieveReferences(Object newObj, ClassDescriptor cld, boolean forced)
throws PersistenceBrokerException
       {
           Iterator i = cld.getObjectReferenceDescriptors().iterator();
  -        ObjectReferenceDescriptor rds = null;
  +
           // turn off auto prefetching for related proxies
  -        Class saveClassToPrefetch = classToPrefetch;
  +        final Class saveClassToPrefetch = classToPrefetch;
           classToPrefetch = null;
  +
           pb.getInternalCache().enableMaterializationCache();
           try
           {
               while (i.hasNext())
               {
  -                rds = (ObjectReferenceDescriptor) i.next();
  +                ObjectReferenceDescriptor rds = (ObjectReferenceDescriptor) i.next();
                   retrieveReference(newObj, cld, rds, forced);
               }
   
  @@ -447,7 +454,10 @@
               pb.getInternalCache().doLocalClear();
               throw e;
           }
  -        classToPrefetch = saveClassToPrefetch;
  +        finally
  +        {
  +            classToPrefetch = saveClassToPrefetch;
  +        }
       }
   
      /**
  @@ -682,7 +692,7 @@
           return fkQuery;
       }
   
  -        /**
  +    /**
        * Get Foreign key query for m:n <br>
        * supports UNIDIRECTIONAL m:n using QueryByMtoNCriteria
        * @return org.apache.ojb.broker.query.QueryByCriteria
  @@ -704,9 +714,8 @@
           }
           for (int i = 0; i < itemClassFks.length; i++)
           {
  -            criteria.addColumnEqualToField(
  -                cod.getIndirectionTable() + "." + itemClassFks[i].toString(),
  -                refCld.getPkFields()[i].getAttributeName());
  +            criteria.addColumnEqualToField(cod.getIndirectionTable() + "." + itemClassFks[i],
  +                    refCld.getPkFields()[i].getAttributeName());
           }
   
           return QueryFactory.newQuery(refCld.getClassOfObject(), cod.getIndirectionTable(),
criteria);
  @@ -767,26 +776,30 @@
       public void retrieveCollections(Object newObj, ClassDescriptor cld, boolean forced)
throws PersistenceBrokerException
       {
           Iterator i = cld.getCollectionDescriptors().iterator();
  -        CollectionDescriptor cds;
  +
           // turn off auto prefetching for related proxies
  -        Class saveClassToPrefetch = classToPrefetch;
  +        final Class saveClassToPrefetch = classToPrefetch;
           classToPrefetch = null;
  +
           pb.getInternalCache().enableMaterializationCache();
           try
           {
               while (i.hasNext())
               {
  -                cds = (CollectionDescriptor) i.next();
  +                CollectionDescriptor cds = (CollectionDescriptor) i.next();
                   retrieveCollection(newObj, cld, cds, forced);
               }
               pb.getInternalCache().disableMaterializationCache();
           }
  -        catch(RuntimeException e)
  +        catch (RuntimeException e)
           {
               pb.getInternalCache().doLocalClear();
               throw e;
           }
  -        classToPrefetch = saveClassToPrefetch;
  +        finally
  +        {
  +            classToPrefetch = saveClassToPrefetch;
  +        }
       }
   
   
  @@ -923,7 +936,7 @@
                   prefetchingAll = false;
               }
   
  -            Class saveClassToPrefetch = classToPrefetch;
  +            final Class saveClassToPrefetch = classToPrefetch;
               classToPrefetch = prefetcher.getItemClassDescriptor().getClassOfObject();
               try
               {
  
  
  

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