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/otm/swizzle CopySwizzling.java
Date Sun, 18 Jan 2004 14:36:12 GMT
olegnitz    2004/01/18 06:36:12

  Modified:    src/java/org/apache/ojb/broker/core
                        QueryReferenceBroker.java
               src/java/org/apache/ojb/broker/metadata
                        RepositoryXmlHandler.java
               src/java/org/apache/ojb/otm/swizzle CopySwizzling.java
  Log:
  merge branch
  
  Revision  Changes    Path
  1.8       +19 -16    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- QueryReferenceBroker.java	5 Jan 2004 01:10:09 -0000	1.7
  +++ QueryReferenceBroker.java	18 Jan 2004 14:36:11 -0000	1.8
  @@ -171,7 +171,7 @@
                               && (cld.getProxyPrefetchingLimit() > 0)
                               && addRetrievalTask(candidate, this))
                       {
  -                        new PBMaterializationListener(handler, m_retrievalTasks,
  +                        new PBMaterializationListener(candidate, m_retrievalTasks,
                                   this, cld.getProxyPrefetchingLimit());
                       }
                   }
  @@ -246,6 +246,7 @@
           }
           catch (Throwable e)
           {
  +            e.printStackTrace();
               throw new PersistenceBrokerException(e);
           }
       }
  @@ -371,7 +372,7 @@
                       if ((handler != null)
                               && addRetrievalTask(obj, rds))
                       {
  -                        new PBMaterializationListener(handler, m_retrievalTasks,
  +                        new PBMaterializationListener(obj, m_retrievalTasks,
                                   rds, rds.getProxyPrefetchingLimit());
                       }
                   }
  @@ -493,7 +494,7 @@
       {
           if (forced || cds.getCascadeRetrieve())
           {
  -            if ((m_retrievalTasks != null) && !cds.isLazy() 
  +            if ((m_retrievalTasks != null) && !cds.isLazy()
                       && !cds.hasProxyItems()
                       && (cds.getQueryCustomizer() == null))
               {
  @@ -545,7 +546,7 @@
                   {
                       if (addRetrievalTask(obj, cds))
                       {
  -                        new PBCollectionProxyListener((CollectionProxy) value,
  +                        new PBCollectionProxyListener(obj,
                                   m_retrievalTasks, cds, cds.getProxyPrefetchingLimit());
                       }
                   }
  @@ -726,15 +727,15 @@
       {
           private IndirectionHandler _listenedHandler;
   
  -        PBMaterializationListener(IndirectionHandler listenedHandler,
  +        PBMaterializationListener(Object owner,
                   HashMap retrievalTasks, Object key, int limit)
           {
  -            super(listenedHandler, retrievalTasks, key, limit);
  +            super(owner, retrievalTasks, key, limit);
           }
   
  -        protected void addThisListenerTo(Object listenedObject)
  +        protected void addThisListenerTo(Object owner)
           {
  -            _listenedHandler = ProxyHelper.getIndirectionHandler(listenedObject);
  +            _listenedHandler = ProxyHelper.getIndirectionHandler(owner);
   
               if (_listenedHandler != null)
               {
  @@ -782,7 +783,7 @@
           private int _limit;
           protected Object _key;
   
  -        PBPrefetchingListener(Object listenedObject, HashMap retrievalTasks,
  +        PBPrefetchingListener(Object owner, HashMap retrievalTasks,
                   Object key, int limit)
           {
               _retrievalTasks = retrievalTasks;
  @@ -792,11 +793,11 @@
               {
                   prefetchingListeners = new ArrayList();
               }
  -            addThisListenerTo(listenedObject);
  +            addThisListenerTo(owner);
               prefetchingListeners.add(this);
           }
   
  -        abstract protected void addThisListenerTo(Object listenedObject);
  +        abstract protected void addThisListenerTo(Object owner);
   
           abstract protected void removeThisListener();
   
  @@ -860,15 +861,17 @@
       {
           CollectionProxy _listenedCollection;
   
  -        PBCollectionProxyListener(CollectionProxy listenedCollection,
  +        PBCollectionProxyListener(Object owner,
                   HashMap retrievalTasks, CollectionDescriptor key, int limit)
           {
  -            super(listenedCollection, retrievalTasks, key, limit);
  +            super(owner, retrievalTasks, key, limit);
           }
   
  -        protected void addThisListenerTo(Object listenedObject)
  +        protected void addThisListenerTo(Object owner)
           {
  -            _listenedCollection = (CollectionProxy) listenedObject;
  +            PersistentField collectionField =
  +                    ((CollectionDescriptor) _key).getPersistentField();
  +            _listenedCollection = (CollectionProxy) collectionField.get(owner);
               _listenedCollection.addListener(this);
           }
   
  
  
  
  1.53      +27 -27    db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
  
  Index: RepositoryXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- RepositoryXmlHandler.java	11 Jan 2004 01:26:31 -0000	1.52
  +++ RepositoryXmlHandler.java	18 Jan 2004 14:36:12 -0000	1.53
  @@ -163,7 +163,7 @@
        */
       public void endDocument()
       {
  -    	AnonymousPersistentFieldHelper.computeInheritedPersistentFields(m_repository);
  +        AnonymousPersistentFieldHelper.computeInheritedPersistentFields(m_repository);
           logger.debug("endDoc");
       }
   
  @@ -272,10 +272,10 @@
                           String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                           if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT)
+ ": " + proxyPrefetchingLimit);
                           if (proxyPrefetchingLimit == null)
  -			            {
  +                        {
                               m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
  -			            }
  -			            else
  +                        }
  +                        else
                           {
                               m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                           }
  @@ -308,9 +308,9 @@
   
                           //set accept-locks attribute
                           String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS));
  -						if (acceptLocks==null)
  -							acceptLocks="true"; // default is true
  -						logger.debug("     " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
  +                        if (acceptLocks==null)
  +                            acceptLocks="true"; // default is true
  +                        logger.debug("     " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
                           if (isDebug) logger.debug("     " + tags.getTagById(ACCEPT_LOCKS)
+ ": " + acceptLocks);
                           boolean b = (Boolean.valueOf(acceptLocks)).booleanValue();
                           m_CurrentCLD.setAcceptLocks(b);
  @@ -391,11 +391,11 @@
   
                           if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
                           {
  -                        	m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId);
  +                            m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId);
                           }
                           else
                           {
  -                        	m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
  +                            m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
                           }
                           m_CurrentFLD.setAccess(strAccess);
                           m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
  @@ -408,12 +408,12 @@
   
                           if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
                           {
  -                        	m_CurrentFLD.setPersistentField(null, fieldName);
  +                            m_CurrentFLD.setPersistentField(null, fieldName);
                           }
                           else
                           {
  -                        	String classname = m_CurrentCLD.getClassNameOfObject();
  -                        	m_CurrentFLD.setPersistentField(ClassHelper.getClass(classname),
fieldName);
  +                            String classname = m_CurrentCLD.getClassNameOfObject();
  +                            m_CurrentFLD.setPersistentField(ClassHelper.getClass(classname),
fieldName);
                           }
   
                           String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
  @@ -545,12 +545,12 @@
                           String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                           if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT)
+ ": " + proxyPrefetchingLimit);
                           if (proxyPrefetchingLimit == null)
  -			            {
  -                            m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
  -			            }
  -			            else
                           {
  -                            m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
  +                            m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
  +                        }
  +                        else
  +                        {
  +                            m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                           }
   
                           // set refresh attribute
  @@ -670,12 +670,12 @@
                           String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
                           if (isDebug) logger.debug("     " + tags.getTagById(PROXY_PREFETCHING_LIMIT)
+ ": " + proxyPrefetchingLimit);
                           if (proxyPrefetchingLimit == null)
  -			            {
  -                            m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
  -			            }
  -			            else
                           {
  -                            m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
  +                            m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
  +                        }
  +                        else
  +                        {
  +                            m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
                           }
   
                           // set refresh attribute
  @@ -843,7 +843,7 @@
                           InsertProcedureDescriptor proc =
                               new InsertProcedureDescriptor(m_CurrentCLD,
                                                             procName,
  -														  Boolean.valueOf(includeAllFields).booleanValue());
  +                                                          Boolean.valueOf(includeAllFields).booleanValue());
                           m_CurrentProcedure = proc;
   
                           // Get the name of the field ref that will receive the
  @@ -871,7 +871,7 @@
                           UpdateProcedureDescriptor proc =
                               new UpdateProcedureDescriptor(m_CurrentCLD,
                                                             procName,
  -														  Boolean.valueOf(includeAllFields).booleanValue());
  +                                                          Boolean.valueOf(includeAllFields).booleanValue());
                           m_CurrentProcedure = proc;
   
                           // Get the name of the field ref that will receive the
  @@ -899,7 +899,7 @@
                           DeleteProcedureDescriptor proc =
                               new DeleteProcedureDescriptor(m_CurrentCLD,
                                                             procName,
  -														  Boolean.valueOf(includeAllPkFields).booleanValue());
  +                                                          Boolean.valueOf(includeAllPkFields).booleanValue());
                           m_CurrentProcedure = proc;
   
                           // Get the name of the field ref that will receive the
  @@ -949,7 +949,7 @@
                           // Set the value for the argument.
                           if ((fieldRefName != null) && (fieldRefName.trim().length()
!= 0)) {
                               arg.setValue(fieldRefName,
  -										 Boolean.valueOf(returnValue).booleanValue());
  +                                         Boolean.valueOf(returnValue).booleanValue());
                           }
   
                           // Add the argument to the procedure.
  
  
  
  1.6       +23 -9     db-ojb/src/java/org/apache/ojb/otm/swizzle/CopySwizzling.java
  
  Index: CopySwizzling.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/swizzle/CopySwizzling.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CopySwizzling.java	25 Jul 2003 00:22:00 -0000	1.5
  +++ CopySwizzling.java	18 Jan 2004 14:36:12 -0000	1.6
  @@ -5,6 +5,7 @@
   import java.util.Iterator;
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.accesslayer.CollectionProxy;
   import org.apache.ojb.broker.cache.ObjectCache;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
  @@ -104,25 +105,37 @@
                   Collection oldCol;
   
                   newCol = (Collection) field.get(newObj);
  -                if (newCol == null)
  +                if ((newCol == null)
  +                        || ((newCol instanceof CollectionProxy)
  +                            && !((CollectionProxy) newCol).isLoaded()))
                   {
  -                    field.set(oldObj, null);
  +                    field.set(oldObj, newCol);
                       continue;
                   }
   
                   oldCol = (Collection) field.get(oldObj);
                   if (oldCol == null)
                   {
  -                    try
  +                    if (newCol instanceof CollectionProxy)
                       {
  -                        oldCol = (Collection) newCol.getClass().newInstance();
  +                        CollectionProxy cp = (CollectionProxy) newCol;
  +                        oldCol = new CollectionProxy(pb.getPBKey(), cp.getData().getClass(),
null);
  +                        oldCol.clear();
                       }
  -                    catch (Exception ex)
  +                    else
                       {
  -                        System.err.println("Cannot instantiate collection field which is
neither Collection nor array: " + field);
  -                        ex.printStackTrace();
  -                        return newObj;
  +                        try
  +                        {
  +                            oldCol = (Collection) newCol.getClass().newInstance();
  +                        }
  +                        catch (Exception ex)
  +                        {
  +                            System.err.println("Cannot instantiate collection field which
is neither Collection nor array: " + field);
  +                            ex.printStackTrace();
  +                            return newObj;
  +                        }
                       }
  +                    field.set(oldObj, oldCol);
                   }
                   else
                   {
  @@ -144,7 +157,7 @@
               {
                   Object newArray = field.get(newObj);
                   int length = Array.getLength(newArray);
  -                Object oldArray = 
  +                Object oldArray =
                           Array.newInstance(field.getType().getComponentType(), length);
   
                   for (int i = 0; i < length; i++)
  @@ -158,6 +171,7 @@
                       }
                       Array.set(oldArray, i, oldRelObj);
                   }
  +                field.set(oldObj, oldArray);
               }
               else
               {
  
  
  

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