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/accesslayer/sql SqlQueryStatement.java
Date Fri, 20 Feb 2004 18:02:39 GMT
brj         2004/02/20 10:02:39

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  Fixed issue OJB243 (wrong columns of extents)
  
  Revision  Changes    Path
  1.64      +28 -9     db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- SqlQueryStatement.java	14 Feb 2004 19:36:53 -0000	1.63
  +++ SqlQueryStatement.java	20 Feb 2004 18:02:39 -0000	1.64
  @@ -1066,6 +1066,8 @@
   
       /**
        * add a join between two aliases
  +     * 
  +     * TODO BRJ : This needs refactoring, it looks kind of weird
        *
        * no extents
        * A1   -> A2
  @@ -1093,11 +1095,9 @@
        */
       private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[]
rightKeys, boolean outer, String name)
       {
  -        Join join;
           TableAlias extAlias, rightCopy;
   
  -        join = new Join(left, leftKeys, right, rightKeys, outer, name);
  -        left.addJoin(join);
  +        left.addJoin(new Join(left, leftKeys, right, rightKeys, outer, name));
   
           // build join between left and extents of right
           if (right.hasExtents())
  @@ -1105,8 +1105,9 @@
               for (int i = 0; i < right.extents.size(); i++)
               {
                   extAlias = (TableAlias) right.extents.get(i);
  -                join = new Join(left, leftKeys, extAlias, rightKeys, true, name);
  -                left.addJoin(join);
  +                FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])rightKeys);
  +
  +                left.addJoin(new Join(left, leftKeys, extAlias, extKeys, true, name));
               }
           }
   
  @@ -1116,19 +1117,37 @@
              for (int i = 0; i < left.extents.size(); i++)
              {
                  extAlias = (TableAlias) left.extents.get(i);
  +               FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])leftKeys);
                  rightCopy = right.copy("C" + i);
   
                  // copies are treated like normal extents
                  right.extents.add(rightCopy);
                  right.extents.addAll(rightCopy.extents);
   
  -               addJoin(extAlias, leftKeys, rightCopy ,rightKeys, true ,name);
  +               addJoin(extAlias, extKeys, rightCopy ,rightKeys, true ,name);
              }
           }
  -
  -
       }
   
  +    /**
  +     * Get the FieldDescriptors of the extent based on the FieldDescriptors of the parent
  +     * @param extAlias
  +     * @param fds
  +     * @return
  +     */
  +    private FieldDescriptor[] getExtentFieldDescriptors(TableAlias extAlias, FieldDescriptor[]
fds)
  +    {
  +        FieldDescriptor[] result = new FieldDescriptor[fds.length];
  +        
  +        for (int i = 0; i < fds.length; i++)
  +        {
  +            result[i] = extAlias.cld.getFieldDescriptorByName(fds[i].getAttributeName());
  +        }
  +            
  +        return result;
  +    }
  +                       
  +    
       private char getAliasChar()
       {
           char result = 'A';
  
  
  

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