aclute      2005/04/28 13:38:38

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  [JIRA]OJB-35 -- Create new getPlainDBObject that does only the DB call, and 
now caching or reference retrieval. Alllows for retrieveReference to use it 
without stomping on it's cached instance
  
  Revision  Changes    Path
  1.118     +32 -15    
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.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- PersistenceBrokerImpl.java        23 Apr 2005 14:39:51 -0000      1.117
  +++ PersistenceBrokerImpl.java        28 Apr 2005 20:38:38 -0000      1.118
  @@ -1453,23 +1453,16 @@
       }
   
       /**
  -     * Retrieve an object by it's identity from the database
  +     * Retrieve an plain object (without populated references) by it's 
identity
  +     * from the database
        *
  -     * @param oid
  -     * @return
  +     * @param cld the real [EMAIL PROTECTED] 
org.apache.ojb.broker.metadata.ClassDescriptor} of the object to refresh
  +     * @param oid the [EMAIL PROTECTED] org.apache.ojb.broker.Identity} of 
the object
  +     * @return A new plain object read from the database or <em>null</em> if 
not found
        * @throws ClassNotPersistenceCapableException
        */
  -    private Object getDBObject(Identity oid) throws 
ClassNotPersistenceCapableException
  +    private Object getPlainDBObject(ClassDescriptor cld, Identity oid) 
throws ClassNotPersistenceCapableException
       {
  -        Class c = oid.getObjectsRealClass();
  -
  -        if (c == null)
  -        {
  -            logger.info("Real class for used Identity object is 'null', use 
top-level class instead");
  -            c = oid.getObjectsTopLevelClass();
  -        }
  -
  -        ClassDescriptor cld = getClassDescriptor(c);
           Object newObj = null;
   
           // Class has a directly mapped table and we lookup this table first:
  @@ -1496,6 +1489,30 @@
                   }
               }
           }
  +        return newObj;
  +    }
  +    
  +    
  +    
  +    /**
  +     * Retrieve an object by it's identity from the database
  +     *
  +     * @param oid
  +     * @return
  +     * @throws ClassNotPersistenceCapableException
  +     */
  +    private Object getDBObject(Identity oid) throws 
ClassNotPersistenceCapableException
  +    {
  +        Class c = oid.getObjectsRealClass();
  +
  +        if (c == null)
  +        {
  +            logger.info("Real class for used Identity object is 'null', use 
top-level class instead");
  +            c = oid.getObjectsTopLevelClass();
  +        }
  +
  +        ClassDescriptor cld = getClassDescriptor(c);
  +        Object newObj = getPlainDBObject(cld,oid);        
   
           // loading references is useful only when the Object could be found 
in db:
           if (newObj != null)
  @@ -1628,7 +1645,7 @@
       private void refreshInstance(Object cachedInstance, Identity oid, 
ClassDescriptor cld)
       {
           // read in fresh copy from the db
  -        Object freshInstance = getDBObject(oid);
  +        Object freshInstance = getPlainDBObject(cld, oid);
   
           // update all primitive typed attributes
           FieldDescriptor[] fields = cld.getFieldDescriptions();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to