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 Fri, 04 Jul 2003 21:45:18 GMT
brj         2003/07/04 14:45:18

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  use real object in assertFkAssignment
  
  Revision  Changes    Path
  1.23      +23 -26    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- PersistenceBrokerImpl.java	2 Jul 2003 19:52:18 -0000	1.22
  +++ PersistenceBrokerImpl.java	4 Jul 2003 21:45:18 -0000	1.23
  @@ -696,48 +696,45 @@
   
       /**
        * update the the foreign key fields of obj with the key fields of ref
  -     * @param obj
  -     * @param ref referenced object
  +     * 
  +     * @param obj referencing object or proxy
  +     * @param ref referenced object or proxy
        * @param rds
        */
       private void assertFkAssignment(Object obj, Object ref, ObjectReferenceDescriptor rds)
       {
  -        Class objClass = ProxyHelper.getRealClass(obj);
  +        // BRJ: ensure real object
  +        Object realObj = ProxyHelper.getRealObject(obj);
  +        Class objClass = realObj.getClass();
           ClassDescriptor objCld = descriptorRepository.getDescriptorFor(objClass);
           FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
  +        Object[] refPkValues;
   
  -         // MBAIRD
  -         // we have 'disassociated' this object from the referenced object,
  -         // the object representing the ord is now null, so set the fk to null.
  +        if (objFkFields == null)
  +        {
  +            throw new PersistenceBrokerException("No ForeignKeyFields !");
  +        }
  +
  +        // MBAIRD: we have 'disassociated' this object from the referenced object,
  +        // the object representing the ord is now null, so set the fk to null.
           if (ref == null)
           {
  -            if (objFkFields!= null)
  -            {
  -                FieldDescriptor fld;
  -                for (int i = 0; i < objFkFields.length; i++)
  -                {
  -                    fld = objFkFields[i];
  -                    fld.getPersistentField().set(obj, null);
  -                }
  -            }
  +            refPkValues = new Object[objFkFields.length];
           }
           else
           {
               // BRJ: ref may be Proxy
               Class refClass = ProxyHelper.getRealClass(ref);
               ClassDescriptor refCld = descriptorRepository.getDescriptorFor(refClass);
  -            Object[] refPkValues = brokerHelper.getKeyValues(refCld, ref, false);
   
  -            if (objFkFields != null)
  -            {
  -                FieldDescriptor fld;
  -                for (int i = 0; i < objFkFields.length; i++)
  -                {
  -                    fld = objFkFields[i];
  -                    fld.getPersistentField().set(obj, refPkValues[i]);
  -                }
  -            }
  +            refPkValues = brokerHelper.getKeyValues(refCld, ref, false);
           }
  +
  +        for (int i = 0; i < objFkFields.length; i++)
  +        {
  +            objFkFields[i].getPersistentField().set(realObj, refPkValues[i]);
  +        }
  +
       }
   
       /**
  
  
  

Mime
View raw message