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/otm/core BaseConnection.java
Date Fri, 26 Aug 2005 19:25:59 GMT
brj         2005/08/26 12:25:59

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        PagingIterator.java OJBIterator.java
                        RsIterator.java ChainingIterator.java
               src/java/org/apache/ojb/broker/core
                        QueryReferenceBroker.java
               src/java/org/apache/ojb/otm/core BaseConnection.java
  Log:
  fix for OJB-68
  
  Revision  Changes    Path
  1.12      +16 -20    db-ojb/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java
  
  Index: PagingIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/PagingIterator.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- PagingIterator.java	11 Aug 2004 00:42:52 -0000	1.11
  +++ PagingIterator.java	26 Aug 2005 19:25:58 -0000	1.12
  @@ -94,9 +94,7 @@
           m_iterator.setAutoRelease(autoRelease);
       }
   
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see org.apache.ojb.broker.accesslayer.OJBIterator#size()
   	 */
       public int size() throws PersistenceBrokerException
  @@ -111,7 +109,7 @@
           }
       }
   
  -    /* (non-Javadoc)
  +    /**
        * @see org.apache.ojb.broker.accesslayer.OJBIterator#fullSize()
        */
       public int fullSize() throws PersistenceBrokerException
  @@ -119,9 +117,7 @@
           return m_fullSize;
       }
       
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see org.apache.ojb.broker.accesslayer.OJBIterator#absolute(int)
   	 */
       public boolean absolute(int row) throws PersistenceBrokerException
  @@ -142,9 +138,7 @@
           return m_iterator.absolute(newPosition);
       }
   
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see org.apache.ojb.broker.accesslayer.OJBIterator#relative(int)
   	 */
       public boolean relative(int row) throws PersistenceBrokerException
  @@ -152,9 +146,7 @@
           return absolute(m_currentCursorPosition - (m_startAt - 1) + row);
       }
   
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see org.apache.ojb.broker.accesslayer.OJBIterator#releaseDbResources()
   	 */
       public void releaseDbResources()
  @@ -170,9 +162,7 @@
           throw new UnsupportedOperationException("remove not supported by PagingIterator");
       }
   
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see java.util.Iterator#hasNext()
   	 */
       public boolean hasNext()
  @@ -189,9 +179,7 @@
   
       }
   
  -    /*
  -	 * (non-Javadoc)
  -	 * 
  +    /**
   	 * @see java.util.Iterator#next()
   	 */
       public Object next()
  @@ -199,4 +187,12 @@
           m_currentCursorPosition++;
           return m_iterator.next();
       }
  +    
  +    /**
  +     * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
  +     */
  +    public void disableLifeCycleEvents()
  +    {
  +        m_iterator.disableLifeCycleEvents();       
  +    }
   }
  
  
  
  1.11      +6 -1      db-ojb/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java
  
  Index: OJBIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/OJBIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- OJBIterator.java	11 Aug 2004 00:42:52 -0000	1.10
  +++ OJBIterator.java	26 Aug 2005 19:25:58 -0000	1.11
  @@ -108,4 +108,9 @@
        * @see #releaseDbResources()
        */
       boolean isClosed();
  +    
  +    /**
  +     * Do not fire any PBLifeCycleEvent when reading next item. 
  +     */
  +    public void disableLifeCycleEvents();
   }
  
  
  
  1.76      +18 -4     db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java
  
  Index: RsIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/RsIterator.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- RsIterator.java	24 Apr 2005 11:54:04 -0000	1.75
  +++ RsIterator.java	26 Aug 2005 19:25:58 -0000	1.76
  @@ -144,6 +144,9 @@
        */
       private boolean autoRelease = true;
   
  +    /** if true do not fire PBLifeCycleEvent. */
  +    private boolean disableLifeCycleEvents = false;
  +
       /**
        * RsIterator constructor.
        *
  @@ -257,9 +260,12 @@
   
                   // Invoke events on PersistenceBrokerAware instances and listeners
                   // set target object
  -                getAfterLookupEvent().setTarget(obj);
  -                getBroker().fireBrokerEvent(getAfterLookupEvent());
  -                getAfterLookupEvent().setTarget(null);
  +                if (!disableLifeCycleEvents)
  +                {
  +                    getAfterLookupEvent().setTarget(obj);
  +                    getBroker().fireBrokerEvent(getAfterLookupEvent());
  +                    getAfterLookupEvent().setTarget(null);
  +                }    
                   return obj;
               }
               else
  @@ -924,6 +930,14 @@
           return m_inBatchedMode;
       }
   
  +    /**
  +     * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
  +     */
  +    public void disableLifeCycleEvents()
  +    {
  +        disableLifeCycleEvents = true;
  +    }
  +    
       //***********************************************************
       // inner classes
       //***********************************************************
  
  
  
  1.15      +14 -1     db-ojb/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java
  
  Index: ChainingIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ChainingIterator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ChainingIterator.java	11 Aug 2004 00:42:52 -0000	1.14
  +++ ChainingIterator.java	26 Aug 2005 19:25:58 -0000	1.15
  @@ -427,4 +427,17 @@
   
           return result;
       }
  +    
  +    /**
  +     * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
  +     */
  +    public void disableLifeCycleEvents()
  +    {
  +        Iterator iterators = m_rsIterators.iterator();
  +        while (iterators.hasNext())
  +        {
  +            OJBIterator iter = (OJBIterator) iterators.next();
  +            iter.disableLifeCycleEvents();
  +        }        
  +    }
   }
  
  
  
  1.38      +17 -1     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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- QueryReferenceBroker.java	27 Apr 2005 19:21:52 -0000	1.37
  +++ QueryReferenceBroker.java	26 Aug 2005 19:25:58 -0000	1.38
  @@ -25,6 +25,7 @@
   
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.ManageableCollection;
  +import org.apache.ojb.broker.PBLifeCycleEvent;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.accesslayer.CollectionCreationContext;
   import org.apache.ojb.broker.accesslayer.OJBIterator;
  @@ -71,10 +72,12 @@
       private final boolean batchRetrieval = true;
       private final boolean prefetchProxies = true;
       private Class classToPrefetch;
  +    private PBLifeCycleEvent afterLookupEvent;
   
       public QueryReferenceBroker(final PersistenceBrokerImpl pb)
       {
           this.pb = pb;
  +        afterLookupEvent = new PBLifeCycleEvent(pb, PBLifeCycleEvent.Type.AFTER_LOOKUP);
       }
   
       /**
  @@ -120,6 +123,7 @@
           {
               // now iterate over all elements and add them to the new collection
               iter = pb.getIteratorFromQuery(query, cld);
  +            iter.disableLifeCycleEvents();
   
               // BRJ : get fullSize for Query
               // to be removed when Query.fullSize is removed
  @@ -182,6 +186,18 @@
                       classToPrefetch = saveClassToPrefetch;
                   }
               }
  +            
  +            // BRJ: fire LifeCycleEvents after execution of RetrievalTasks
  +            // to ensure objects are fully materialized
  +            Iterator resultIter = collection.ojbIterator(pb);
  +            while (resultIter.hasNext())
  +            {
  +                Object obj = resultIter.next();
  +                afterLookupEvent.setTarget(obj);
  +                pb.fireBrokerEvent(afterLookupEvent);
  +                afterLookupEvent.setTarget(null);
  +            }
  +
           }
           catch(RuntimeException e)
           {
  
  
  
  1.44      +15 -16    db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java
  
  Index: BaseConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/core/BaseConnection.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- BaseConnection.java	2 Apr 2005 09:44:40 -0000	1.43
  +++ BaseConnection.java	26 Aug 2005 19:25:58 -0000	1.44
  @@ -546,9 +546,7 @@
               done();
           }
   
  -        /*
  -         * (non-Javadoc)
  -         * 
  +        /**
            * @see org.apache.ojb.broker.accesslayer.OJBIterator#absolute(int)
            */
           public boolean absolute(int row) throws PersistenceBrokerException
  @@ -556,9 +554,7 @@
               return _it.absolute(row);
           }
   
  -        /*
  -         * (non-Javadoc)
  -         * 
  +        /**
            * @see org.apache.ojb.broker.accesslayer.OJBIterator#fullSize()
            */
           public int fullSize() throws PersistenceBrokerException
  @@ -566,9 +562,7 @@
               return _it.fullSize();
           }
   
  -        /*
  -         * (non-Javadoc)
  -         * 
  +        /**
            * @see org.apache.ojb.broker.accesslayer.OJBIterator#relative(int)
            */
           public boolean relative(int row) throws PersistenceBrokerException
  @@ -576,9 +570,7 @@
               return _it.relative(row);
           }
   
  -        /*
  -         * (non-Javadoc)
  -         * 
  +        /**
            * @see org.apache.ojb.broker.accesslayer.OJBIterator#releaseDbResources()
            */
           public void releaseDbResources()
  @@ -591,15 +583,22 @@
               return _it.isClosed();
           }
   
  -        /*
  -         * (non-Javadoc)
  -         * 
  +        /**
            * @see org.apache.ojb.broker.accesslayer.OJBIterator#size()
            */
           public int size() throws PersistenceBrokerException
           {
               return _it.size();
           }
  +        
  +        /**
  +         * @see org.apache.ojb.broker.accesslayer.OJBIterator#disableLifeCycleEvents()
  +         */
  +        public void disableLifeCycleEvents()
  +        {
  +            _it.disableLifeCycleEvents();
  +        }
  +
       }
   
       private class OTMOQLQueryImpl extends OQLQueryImpl
  
  
  

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