db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata ObjectReferenceDescriptor.java
Date Wed, 16 Nov 2005 01:39:04 GMT
arminw      2005/11/15 17:39:04

  Modified:    src/java/org/apache/ojb/broker/metadata
                        ObjectReferenceDescriptor.java
  Log:
  when lookup FK field-descriptor note by field index too, last part of OJB-55 patch
  
  Revision  Changes    Path
  1.47      +24 -26    db-ojb/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java
  
  Index: ObjectReferenceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- ObjectReferenceDescriptor.java	27 Aug 2005 12:16:55 -0000	1.46
  +++ ObjectReferenceDescriptor.java	16 Nov 2005 01:39:04 -0000	1.47
  @@ -123,35 +123,34 @@
                       cld = getClassDescriptor().getRepository().getDescriptorFor(firstConcreteClass);
                   }
                   List ret = new ArrayList();
  -
                   for (int i = 0; i < fkFields.size(); i++)
                   {
                       ForeignKey fk = (ForeignKey) fkFields.get(i);
                       FieldDescriptor fkfd = null;
  -                    if (fk.fkField instanceof Integer)
  -                    {
  -                        Integer index = (Integer) fk.fkField;
  -                        fkfd = cld.getFieldDescriptorByIndex(index.intValue());
  -                    }
  -                    else
  +                    /*
  +                    OJB-55
  +                    it's possible that the FK field is declared in the super classes of
this object,
  +                    so we can search for a valid field in super class-descriptor
  +                    */
  +                    ClassDescriptor tmp = cld;
  +                    while(tmp != null)
                       {
  -                        /*
  -                        arminw:
  -                        it's possible that the FK field is declared in the super classes
of this object,
  -                        so we can search for a valid field in super class-descriptor
  -                        */
  -                        ClassDescriptor tmp = cld;
  -                        while(tmp != null)
  +                        if (fk.fkField instanceof Integer)
  +                        {
  +                            Integer index = (Integer) fk.fkField;
  +                            fkfd = cld.getFieldDescriptorByIndex(index.intValue());
  +                        }
  +                        else
                           {
                               fkfd = tmp.getFieldDescriptorByName((String) fk.fkField);
  -                            if(fkfd != null)
  -                            {
  -                                break;
  -                            }
  -                            else
  -                            {
  -                                tmp = tmp.getSuperClassDescriptor();
  -                            }
  +                        }
  +                        if(fkfd != null)
  +                        {
  +                            break;
  +                        }
  +                        else
  +                        {
  +                            tmp = tmp.getSuperClassDescriptor();
                           }
                       }
                       if (fkfd == null)
  @@ -194,8 +193,7 @@
               // FieldConversion fc = fmd.getFieldConversion();
               // Object val = fc.javaToSql(f.get(obj));
   
  -            Object val = f.get(obj);
  -            result[i] = val;
  +            result[i] = f.get(obj);
           }
           return result;
       }
  @@ -448,7 +446,7 @@
        */
       public boolean getCascadeStore()
       {
  -        return getCascadingStore() == CASCADE_OBJECT ? true : false;
  +        return getCascadingStore() == CASCADE_OBJECT;
       }
   
       /**
  @@ -492,7 +490,7 @@
        */
       public boolean getCascadeDelete()
       {
  -        return getCascadingDelete() == CASCADE_OBJECT ? true : false;
  +        return getCascadingDelete() == CASCADE_OBJECT;
       }
   
       /**
  
  
  

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