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, 20 Jun 2003 19:22:12 GMT
brj         2003/06/20 12:22:12

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  reworked assertFkAssignment
  
  Revision  Changes    Path
  1.15      +13 -17    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PersistenceBrokerImpl.java	20 Jun 2003 09:25:14 -0000	1.14
  +++ PersistenceBrokerImpl.java	20 Jun 2003 19:22:12 -0000	1.15
  @@ -692,40 +692,36 @@
        * @param rds
        */
       private void assertFkAssignment(Object obj, Object ref, ObjectReferenceDescriptor rds)
  -    {
  +    {      
  +        Class objClass = ProxyHelper.getRealClass(obj);
  +        ClassDescriptor objCld = descriptorRepository.getDescriptorFor(objClass);
  +        FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
  +
            // 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)
           {
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  -            FieldDescriptor f[] = rds.getForeignKeyFieldDescriptors(cld);
  -            if (f != null)
  +            if (objFkFields!= null)
               {
  -                for (int i = 0; i < f.length; i++)
  +                FieldDescriptor fld;
  +                for (int i = 0; i < objFkFields.length; i++)
                   {
  -                    f[i].getPersistentField().set(obj, null);
  +                    fld = objFkFields[i];
  +                    fld.getPersistentField().set(obj, null);
                   }
               }
           }
  -
  -        if (
  -            (!(obj instanceof VirtualProxy)) &&
  -            (!(obj instanceof Proxy)) &&
  -            (ref != null)             
  -           )
  +        else
           {
               // BRJ: ref may be Proxy
               Class refClass = ProxyHelper.getRealClass(ref);
               ClassDescriptor refCld = descriptorRepository.getDescriptorFor(refClass);
               Object[] refPkValues = brokerHelper.getKeyValues(refCld, ref, false);
   
  -            ClassDescriptor objCld = descriptorRepository.getDescriptorFor(obj.getClass());
  -            FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
  -
               if (objFkFields != null)
               {
  -                FieldDescriptor fld = null;
  +                FieldDescriptor fld;
                   for (int i = 0; i < objFkFields.length; i++)
                   {
                       fld = objFkFields[i];
  
  
  

Mime
View raw message