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 00:58:38 GMT
arminw      2005/11/15 16:58:38

  Modified:    src/java/org/apache/ojb/broker/metadata Tag: OJB_1_0_RELEASE
                        ObjectReferenceDescriptor.java
  Log:
  when lookup FK field-descriptor note by field index too, last part of OJB-55 patch
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.37.2.4  +28 -19    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.37.2.3
  retrieving revision 1.37.2.4
  diff -u -r1.37.2.3 -r1.37.2.4
  --- ObjectReferenceDescriptor.java	4 Jun 2005 15:03:35 -0000	1.37.2.3
  +++ ObjectReferenceDescriptor.java	16 Nov 2005 00:58:38 -0000	1.37.2.4
  @@ -93,7 +93,7 @@
        */
   	public FieldDescriptor[] getForeignKeyFieldDescriptors(ClassDescriptor mif)
   	{
  -		FieldDescriptor[] foreignKeyFieldDescriptors = null;
  +		FieldDescriptor[] foreignKeyFieldDescriptors;
   		if ((foreignKeyFieldDescriptors = (FieldDescriptor[]) fkFieldMap.get(mif)) == null)
   		{
   			// 1. collect vector of indices of Fk-Fields
  @@ -126,29 +126,39 @@
   					else
   					{
   						fkfd = mif.getFieldDescriptorByName((String) fk);
  +					}
  +                    if (fkfd == null)
  +                    {
                           /*
  +                        OJB-55
                           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
                           */
  -                        if (fkfd == null)
  +                        ClassDescriptor tmp = mif;
  +                        while(tmp.getSuperClassDescriptor() != null)
                           {
  -                            ClassDescriptor tmp = mif;
  -                            while(tmp.getSuperClassDescriptor() != null)
  +                            if (fk instanceof Integer)
  +							{
  +								Integer index = (Integer) fk;
  +								fkfd = tmp.getFieldDescriptorByIndex(index.intValue());
  +							}
  +							else
  +							{
  +								fkfd = tmp.getFieldDescriptorByName((String) fk);
  +							}
  +                            if(fkfd != null)
  +                            {
  +                                break;
  +                            }
  +                            else
                               {
  -                                fkfd = tmp.getFieldDescriptorByName((String) fk);
  -                                if(fkfd != null)
  -                                {
  -                                    break;
  -                                }
  -                                else
  -                                {
  -                                    tmp = tmp.getSuperClassDescriptor();
  -                                }
  +                                tmp = tmp.getSuperClassDescriptor();
                               }
                           }
  -					}
  -					if (fkfd == null)
  +                    }
  +
  +                    if (fkfd == null)
   					{
                           throw new OJBRuntimeException("Incorrect or not found field reference
name '"
                                   + fk + "' in descriptor " + this + " for class-descriptor
'"
  @@ -188,8 +198,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;
       }
  @@ -337,7 +346,7 @@
        */
       public boolean getCascadeStore()
       {
  -        return getCascadingStore() == CASCADE_OBJECT ? true : false;
  +        return getCascadingStore() == CASCADE_OBJECT;
       }
   
       /**
  @@ -381,7 +390,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