User: kvvinaymenon
  Date: 01/07/03 08:20:30

  Modified:    src/main/org/jboss/ejb/plugins/jaws/jdbc Tag: Branch_2_4
                        JDBCDefinedFinderCommand.java
  Log:
  Modified the class so that it uses the query in lower case i.e. lcQuery only for 
string comparisons. The actual sql generated is derived directly from the query 
defined in the finder. If this is not done, any strings presented in the query would 
get converted to lower case and all the corresponding finds fail.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.1  +17 -17    
jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCDefinedFinderCommand.java
  
  Index: JDBCDefinedFinderCommand.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCDefinedFinderCommand.java,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- JDBCDefinedFinderCommand.java     2001/06/13 06:52:17     1.14
  +++ JDBCDefinedFinderCommand.java     2001/07/03 15:20:30     1.14.2.1
  @@ -26,9 +26,9 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Joe Shevland</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Justin Forder</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Michel de Groot</a>
  - * @author Vinay Menon
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Vinay Menon</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>danch (Dan Christopherson</a>
  - * @version $Revision: 1.14 $
  + * @version $Revision: 1.14.2.1 $
    */
   public class JDBCDefinedFinderCommand extends JDBCFinderCommand
   {
  @@ -36,7 +36,7 @@
   
      private int[] parameterArray;
      private TypeMappingMetaData typeMapping;
  -   
  +
      private String fromClause = "";
      private String whereClause = "";
      private String orderClause = "";
  @@ -85,7 +85,7 @@
         // In case of join query:
         // order must explicitly identify tablename.field to order on
         // query must start with "INNER JOIN <table to join with> WHERE
  -      // <regular query with fully identified fields>"      
  +      // <regular query with fully identified fields>"
         if (lcQuery.startsWith(",") || lcQuery.startsWith("inner join")) {
            //this is the case of a 'where' that is build to actually join tables:
            //  ,table2 as foo where foo.col1 = entitytable.col2 AND 
entitytable.filter = {1}
  @@ -98,22 +98,22 @@
               // they mean a findAll.
               log.debug("Strange query for finder "+f.getName()+
                  ". Includes join, but no 'where' clause. Is this a findAll?");
  -            tableList = lcQuery;
  +            tableList = query;
               whereClause = "";
            } else {
  -            tableList = lcQuery.substring(0, whereStart);
  -            whereClause = lcQuery.substring(whereStart);
  +            tableList = query.substring(0, whereStart);
  +            whereClause = query.substring(whereStart);
            }
            fromClause = "FROM "+jawsEntity.getTableName()+tableList;
         } else {
            fromClause = "FROM "+jawsEntity.getTableName();
            if (lcQuery.startsWith("where"))
  -            whereClause = lcQuery;
  -         else 
  -            whereClause = "where "+lcQuery;
  +            whereClause = query;
  +         else
  +            whereClause = "where "+query;
         }
  -      
   
  +
         StringBuffer sqlBuffer = new StringBuffer();
         sqlBuffer.append("SELECT ");
         //where clauseString primaryKeyList = getPkColumnList();
  @@ -134,7 +134,7 @@
         sqlBuffer.append(fromClause);
         sqlBuffer.append(' ');
         sqlBuffer.append(whereClause);
  -      
  +
         if (f.getOrder() != null && !f.getOrder().equals(""))
         {
            orderClause = " ORDER BY "+f.getOrder();
  @@ -154,7 +154,7 @@
         return orderClause;
      }
   
  -   /** helper method to clean the order clause into a list of table.field 
  +   /** helper method to clean the order clause into a list of table.field
       *  entries. This is used only to clean up the algorythm in the ctor.
       *  @return String array containing order fields stripped of 'ASC' or 'DESC'
       *  modifiers.
  @@ -198,7 +198,7 @@
         if(f.getOrder()!=null && f.getOrder()!="")
         {
           String[] checkedOrderTokens = cleanOrderClause(f.getOrder());
  -   
  +
           //Next step is to make up a Set of all pk tokens
           StringTokenizer pkTokens = new StringTokenizer(getPkColumnList(), ",");
           Set setOfPkTokens = new HashSet(pkTokens.countTokens());
  @@ -206,7 +206,7 @@
           {
             setOfPkTokens.add(pkTokens.nextToken().trim());
           }
  -   
  +
           //Now is the time to check for duplicates between pk and order tokens
           int i = 0;
           while(i < checkedOrderTokens.length)
  @@ -218,7 +218,7 @@
             }
             i++;
           }
  -   
  +
           //Ok, build a new order string that we can use later on
           StringBuffer orderTokensToUse = new StringBuffer("");
           i = 0;
  @@ -235,7 +235,7 @@
           strippedOrder = orderTokensToUse.toString();
         }
         return strippedOrder;
  -   }      
  +   }
      // JDBCFinderCommand overrides ------------------------------------
   
      protected void setParameters(PreparedStatement stmt, Object argOrArgs)
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to