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/core PersistenceBrokerImpl.java
Date Sat, 01 Nov 2003 21:04:29 GMT
brj         2003/11/01 13:04:29

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  refactoring using getClassDescriptor()
  
  Revision  Changes    Path
  1.44      +30 -35    db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- PersistenceBrokerImpl.java	1 Nov 2003 20:45:12 -0000	1.43
  +++ PersistenceBrokerImpl.java	1 Nov 2003 21:04:28 -0000	1.44
  @@ -430,7 +430,7 @@
                * 2. register object in markedForDelete map.
                */
               markedForDelete.add(obj);
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  +            ClassDescriptor cld = getClassDescriptor(obj.getClass());
               Identity oid = new Identity(obj, this, cld);
               // Invoke events on PersistenceBrokerAware instances and listeners
               BEFORE_DELETE_EVENT.setTarget(obj);
  @@ -483,43 +483,38 @@
                   QueryByIdentity qbi = (QueryByIdentity) query;
                   Object oid = qbi.getExampleObject();
                   // make sure it's an Identity
  -                if (! (oid instanceof Identity))
  +                if (!(oid instanceof Identity))
                   {
                       oid = new Identity(oid, this);
                   }
  -                query = this.getPKQuery((Identity)oid);
  +                query = this.getPKQuery((Identity) oid);
  +            }
  +
  +            if (!cld.isInterface())
  +            {
  +                this.dbAccess.executeDelete(query, cld);
               }
   
               // if class is an extent, we have to delete all extent classes too
               String lastUsedTable = cld.getFullTableName();
               if (cld.isExtent())
               {
  -                Vector extentClasses = cld.getExtentClasses();
  -                Class ec = null;
  +                Iterator extentClasses = cld.getAllConcreteExtentClasses().iterator();
   
  -                if (!cld.isInterface())
  +                while (extentClasses.hasNext())
                   {
  -                    this.dbAccess.executeDelete(query, cld);
  -                }
  +                    Class ec = (Class) extentClasses.next();
  +                    ClassDescriptor extCld = getClassDescriptor(ec);
   
  -                for (int i = 0; i < extentClasses.size(); i++)
  -                {
  -                    ec = (Class) extentClasses.get(i);
  -                    cld = getClassDescriptor(ec);
                       // read same table only once
  -                    if (!cld.isInterface() && cld.getFullTableName().equals(lastUsedTable))
  +                    if (!extCld.getFullTableName().equals(lastUsedTable))
                       {
  -                        continue;
  +                        lastUsedTable = extCld.getFullTableName();
  +                        this.dbAccess.executeDelete(query, extCld);
                       }
  -                    lastUsedTable = cld.getFullTableName();
  -                    deleteByQuery(query, cld);
                   }
               }
  -            else
  -            {
  -                // no extents
  -                this.dbAccess.executeDelete(query, cld);
  -            }
  +
           }
       }
   
  @@ -657,7 +652,7 @@
                   return;
               }
   
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  +            ClassDescriptor cld = getClassDescriptor(obj.getClass());
               Identity oid = new Identity(obj, this, cld);
               // check if update or insert is needed
               boolean doInsert = false;
  @@ -717,7 +712,7 @@
           // BRJ: ensure real object
           Object realObj = ProxyHelper.getRealObject(obj);
           Class objClass = realObj.getClass();
  -        ClassDescriptor objCld = descriptorRepository.getDescriptorFor(objClass);
  +        ClassDescriptor objCld = getClassDescriptor(objClass);
           FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
           Object[] refPkValues;
   
  @@ -736,7 +731,7 @@
           {
               // BRJ: ref may be Proxy
               Class refClass = ProxyHelper.getRealClass(ref);
  -            ClassDescriptor refCld = descriptorRepository.getDescriptorFor(refClass);
  +            ClassDescriptor refCld = getClassDescriptor(refClass);
   
               refPkValues = brokerHelper.getKeyValues(refCld, ref, false);
           }
  @@ -1005,7 +1000,7 @@
        */
       public void retrieveAllReferences(Object pInstance) throws PersistenceBrokerException
       {
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(pInstance.getClass());
  +        ClassDescriptor cld = getClassDescriptor(pInstance.getClass());
           // force loading of references
           final boolean forced = true;
           retrieveReferences(pInstance, cld, forced);
  @@ -1038,7 +1033,7 @@
        */
       public void retrieveReference(Object pInstance, String pAttributeName) throws PersistenceBrokerException
       {
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(pInstance.getClass());
  +        ClassDescriptor cld = getClassDescriptor(pInstance.getClass());
           CollectionDescriptor cod = cld.getCollectionDescriptorByName(pAttributeName);
           if (cod != null)
           {
  @@ -1388,7 +1383,7 @@
           }
   
           // ensure that top-level extents are used for Identities
  -        return new Identity(rds.getItemClass(), descriptorRepository.getTopLevelClass(rds.getItemClass()),
fkValues);
  +        return new Identity(rds.getItemClass(), getTopLevelClass(rds.getItemClass()), fkValues);
       }
   
       /**
  @@ -1448,7 +1443,7 @@
       {
           if (logger.isDebugEnabled()) logger.debug("getCollectionByQuery (" + collectionClass
+ ", " + itemClass + ", " + query + ")");
   
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(itemClass);
  +        ClassDescriptor cld = getClassDescriptor(itemClass);
           ManageableCollection result = null;
           OJBIterator iter = null;
           boolean isRetrievalTasksCreated = (batchRetrieval && (m_retrievalTasks
== null));
  @@ -1750,7 +1745,7 @@
               c = oid.getObjectsTopLevelClass();
           }
   
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(c);
  +        ClassDescriptor cld = getClassDescriptor(c);
           Object newObj = null;
   
           // Class is NOT an Interface: it has a directly mapped table and we lookup this
table first:
  @@ -1832,7 +1827,7 @@
       public Iterator getIteratorByQuery(Query query) throws PersistenceBrokerException
       {
           Class itemClass = query.getSearchClass();
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(itemClass);
  +        ClassDescriptor cld = getClassDescriptor(itemClass);
           return getIteratorFromQuery(query, cld);
       }
   
  @@ -1870,7 +1865,7 @@
           }
           else
           {
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  +            ClassDescriptor cld = getClassDescriptor(obj.getClass());
               // if specified in the ClassDescriptor the instance must be refreshed
               if (cld.isAlwaysRefresh())
               {
  @@ -1962,7 +1957,7 @@
       {
           if (logger.isDebugEnabled()) logger.debug("getPKEnumerationByQuery " + query);
   
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(query.getSearchClass());
  +        ClassDescriptor cld = getClassDescriptor(query.getSearchClass());
           return new PkEnumeration(query, cld, primaryKeyClass, this);
       }
   
  @@ -1976,7 +1971,7 @@
       public void store(Object obj, ObjectModification mod) throws PersistenceBrokerException
       {
           obj = ProxyHelper.getRealObject(obj);
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  +        ClassDescriptor cld = getClassDescriptor(obj.getClass());
           // this call ensures that all autoincremented primary key attributes are filled
           Identity oid = new Identity(obj, this, cld);
           // select flag for insert / update selection by checking the ObjectModification
  @@ -2476,7 +2471,7 @@
        */
       public Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
       {
  -        ClassDescriptor cld = descriptorRepository.getDescriptorFor(query.getSearchClass());
  +        ClassDescriptor cld = getClassDescriptor(query.getSearchClass());
           return getReportQueryIteratorFromQuery(query, cld);
       }
   
  
  
  

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