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 Wed, 02 Jul 2003 19:52:19 GMT
brj         2003/07/02 12:52:19

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  applied performance patch by John Marshall
  
  Revision  Changes    Path
  1.22      +11 -7     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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- PersistenceBrokerImpl.java	1 Jul 2003 17:41:26 -0000	1.21
  +++ PersistenceBrokerImpl.java	2 Jul 2003 19:52:18 -0000	1.22
  @@ -1249,10 +1249,9 @@
           Class referencedClass, referencedProxy;
           Object[] pkVals = rds.getForeignKeyValues(obj, cld);
           boolean allPkNull = true;
  +        Identity id;
   
  -        //
           // BRJ : check if we have non null pk values
  -        //
           for (int i = 0; i < pkVals.length; i++)
           {
               if (pkVals[i] != null)
  @@ -1261,9 +1260,7 @@
                   break;
               }
           }
  -        //
           // BRJ : if all pk values are null there's no referenced object
  -        //
           if (allPkNull)
           {
               return null;
  @@ -1272,6 +1269,13 @@
           // ensure that top-level extents are used for Identities
           referencedClass = descriptorRepository.getTopLevelClass(rds.getItemClass());
   
  +        id = new Identity(rds.getItemClass(), referencedClass, pkVals);
  +        //JMM : why not see if the object has already been loaded
  +        if ( objectCache.lookup(id) != null )
  +        {   
  +           return getObjectByIdentity(id);
  +        }
  +
           if (rds.isLazy())
           {
               /*
  @@ -1292,7 +1296,7 @@
           {
               try
               {
  -                return VirtualProxy.createProxy(getPBKey(), referencedProxy, new Identity(rds.getItemClass(),referencedClass,
pkVals));
  +                return VirtualProxy.createProxy(getPBKey(), referencedProxy, id);
               }
               catch (Exception e)
               {
  @@ -1302,7 +1306,7 @@
           }
           else
           {
  -            return getObjectByIdentity(new Identity(rds.getItemClass(), referencedClass,
pkVals));
  +            return getObjectByIdentity(id);
           }
       }
   
  
  
  

Mime
View raw message