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, 04 Mar 2005 00:15:10 GMT
mkalen      2005/03/03 16:15:10

  Modified:    src/java/org/apache/ojb/broker/metadata Tag: OJB_1_0_RELEASE
                        DescriptorRepository.java
  Log:
  Keep individual FieldDescriptor order in getAllMappedColumn, to make sure ResultSet-reads
are in SELECT-order. (Fixes all failing ODMG testcases for Oracle, tested with Oracle and
hsqldb.)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.50.2.6  +17 -18    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.50.2.5
  retrieving revision 1.50.2.6
  diff -u -r1.50.2.5 -r1.50.2.6
  --- DescriptorRepository.java	19 Feb 2005 21:49:54 -0000	1.50.2.5
  +++ DescriptorRepository.java	4 Mar 2005 00:15:09 -0000	1.50.2.6
  @@ -16,12 +16,7 @@
    */
   
   import java.io.Serializable;
  -import java.util.ArrayList;
  -import java.util.Collection;
  -import java.util.HashMap;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Map;
  +import java.util.*;
   
   import org.apache.commons.lang.SystemUtils;
   import org.apache.commons.lang.builder.ToStringBuilder;
  @@ -204,8 +199,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())
  @@ -227,21 +230,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