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 MtoNCollectionPrefetcher.java
Date Fri, 06 Feb 2004 20:49:21 GMT
brj         2004/02/06 12:49:21

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        MtoNCollectionPrefetcher.java
  Log:
  do not use distinct queries because of ORA-22901
  
  Revision  Changes    Path
  1.5       +35 -18    db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java
  
  Index: MtoNCollectionPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MtoNCollectionPrefetcher.java	29 Jan 2004 20:31:43 -0000	1.4
  +++ MtoNCollectionPrefetcher.java	6 Feb 2004 20:49:21 -0000	1.5
  @@ -113,7 +113,13 @@
               Iterator iter = getBroker().getIteratorByQuery(queries[i]);
               while (iter.hasNext())
               {
  -                children.add(iter.next());
  +                Object aChild = iter.next();
  +                
  +                // BRJ: simulate the distinct removed from the query
  +                if (!children.contains(aChild))
  +                {
  +                    children.add(aChild);
  +                }    
               }
               
               Iterator mnIter = getBroker().getReportQueryIteratorByQuery(mnQueries[i]);
  @@ -147,8 +153,17 @@
           FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
       
           Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
  -          
  -        return new QueryByMtoNCriteria(cds.getItemClass(), cds.getIndirectionTable(), crit,
true);
  +        
  +        // BRJ: do not use distinct:
  +        // 
  +        // ORA-22901 cannot compare nested table or VARRAY or LOB attributes of an object
type
  +        // Cause: Comparison of nested table or VARRAY or LOB attributes of an 
  +        // object type was attempted in the absence of a MAP or ORDER method.
  +        // Action: Define a MAP or ORDER method for the object type.
  +        //
  +        // Without the distinct the resultset may contain duplicate rows
  +        
  +        return new QueryByMtoNCriteria(cds.getItemClass(), cds.getIndirectionTable(), crit,
false);
       }
   
       
  @@ -163,15 +178,15 @@
           String[] indItemFkCols = getFksToItemClass();
           FieldDescriptor[] pkFields = getOwnerClassDescriptor().getPkFields();
           FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
  -        String[] cols = new String[indFkCols.length + indItemFkCols.length]; 
  -        int[] jdbcTypes = new int[indFkCols.length + indItemFkCols.length]; 
  -        
  +        String[] cols = new String[indFkCols.length + indItemFkCols.length];
  +        int[] jdbcTypes = new int[indFkCols.length + indItemFkCols.length];
  +
           // concatenate the columns[]
  -        System.arraycopy(indFkCols,0,cols,0,indFkCols.length);
  -        System.arraycopy(indItemFkCols,0,cols,indFkCols.length,indItemFkCols.length);
  -        
  +        System.arraycopy(indFkCols, 0, cols, 0, indFkCols.length);
  +        System.arraycopy(indItemFkCols, 0, cols, indFkCols.length, indItemFkCols.length);
  +
           Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
  -        
  +
           // determine the jdbcTypes of the pks
           for (int i = 0; i < pkFields.length; i++)
           {
  @@ -181,11 +196,12 @@
           {
               jdbcTypes[pkFields.length + i] = itemPkFields[i].getJdbcType().getType();
           }
  -                
  -        ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor().getClassOfObject(),
cols, crit, true);
  +
  +        ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor()
  +                .getClassOfObject(), cols, crit, false);
           q.setIndirectionTable(getCollectionDescriptor().getIndirectionTable());
           q.setJdbcTypes(jdbcTypes);
  -        
  +
           return q;
       }
   
  @@ -293,19 +309,20 @@
        * @param itemPkField
        * @return
        */
  -    private Criteria buildPrefetchCriteriaSingleKey(Collection ids, String fkCol, String
itemFkCol, FieldDescriptor itemPkField)
  +    private Criteria buildPrefetchCriteriaSingleKey(Collection ids, String fkCol, String
itemFkCol,
  +            FieldDescriptor itemPkField)
       {
           Criteria crit = new Criteria();
           ArrayList values = new ArrayList();
           Iterator iter = ids.iterator();
           Identity id;
  -       
  +
           while (iter.hasNext())
           {
               id = (Identity) iter.next();
               values.add(id.getPrimaryKeyValues()[0]);
           }
  -    
  +
           switch (values.size())
           {
               case 0 :
  @@ -318,7 +335,7 @@
                   crit.addIn(fkCol, values);
                   break;
           }
  -    
  +
           crit.addEqualToField(itemPkField.getAttributeName(), itemFkCol);
   
           return crit;
  
  
  

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