db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata DescriptorRepository.java
Date Fri, 11 Mar 2005 18:58:56 GMT
mkalen      2005/03/11 10:58:56

  Modified:    src/java/org/apache/ojb/broker/metadata
                        DescriptorRepository.java
  Log:
  Merge with OJB_1_0_RELEASE branch: Keep individual FieldDescriptor order in getAllMappedColumn,
to make sure ResultSet-reads are in SELECT-order. (Fixes ODMG testcases failing with "flow
is already closed" for Oracle.)
  
  Revision  Changes    Path
  1.61      +19 -12    db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- DescriptorRepository.java	16 Jan 2005 12:03:35 -0000	1.60
  +++ DescriptorRepository.java	11 Mar 2005 18:58:56 -0000	1.61
  @@ -22,6 +22,9 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.Vector;
  +import java.util.Set;
  +import java.util.HashSet;
   
   import org.apache.commons.collections.set.ListOrderedSet;
   import org.apache.commons.lang.SystemUtils;
  @@ -206,8 +209,16 @@
   
       private FieldDescriptor[] getAllMappedColumns(List classDescriptors)
       {
  +        /* mkalen: Use an ordered implementation not to loose individual field ordering.
  +             This is especially important for eg Oracle9i platform and LONGVARBINARY columns,
  +            see http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1021777
  +             "If you do not use the SELECT-list order to access data,
  +              then you can lose the stream data."
  +         */
  +        List allFieldDescriptors = new Vector();
  +
  +        Set visitedColumns = new HashSet();
           Iterator it = classDescriptors.iterator();
  -        HashMap map = new HashMap();
           ClassDescriptor temp = null;
           FieldDescriptor[] fields;
           while (it.hasNext())
  @@ -229,21 +240,17 @@
                       In #getClassesMappedToSameTable(...) we make sure that target
                       class has first position in list.
                        */
  -                    if(!map.containsKey(fields[i].getColumnName()))
  +                    final String columnName = fields[i].getColumnName();
  +                    if (!visitedColumns.contains(columnName))
                       {
  -                        map.put(fields[i].getColumnName(), fields[i]);
  +                        visitedColumns.add(columnName);
  +                        allFieldDescriptors.add(fields[i]);
                       }
                   }
               }
           }
  -        Iterator retvalIterator = map.values().iterator();
  -        FieldDescriptor[] retval = new FieldDescriptor[map.size()];
  -        int i = 0;
  -        while (retvalIterator.hasNext())
  -        {
  -            retval[i] = (FieldDescriptor) retvalIterator.next();
  -            i++;
  -        }
  +        FieldDescriptor[] retval = new FieldDescriptor[allFieldDescriptors.size()];
  +        allFieldDescriptors.toArray(retval);
           return retval;
       }
   
  
  
  

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