User: kvvinaymenon
Date: 01/07/03 13:59:55
Modified: src/main/org/jboss/ejb/plugins/jaws/jdbc
JDBCDefinedFinderCommand.java
Log:
Check in for removing bug with the sql being generated from the lower case query
instead of using the query as-is which causes issues in databases where the column and
table names are case sensitive and cases where there are fixed strings in the query
defined since they get converted as well.
Revision Changes Path
1.16 +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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- JDBCDefinedFinderCommand.java 2001/06/21 21:55:31 1.15
+++ JDBCDefinedFinderCommand.java 2001/07/03 20:59:55 1.16
@@ -26,10 +26,10 @@
* @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>
* @author <a href="mailto:[EMAIL PROTECTED]">Bill Burke</a>
- * @version $Revision: 1.15 $
+ * @version $Revision: 1.16 $
*
* Revisions:
* 20010621 Bill Burke: exposed parameterArray through get method.
@@ -40,7 +40,7 @@
private int[] parameterArray;
private TypeMappingMetaData typeMapping;
-
+
private String fromClause = "";
private String whereClause = "";
private String orderClause = "";
@@ -89,7 +89,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}
@@ -102,22 +102,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();
@@ -138,7 +138,7 @@
sqlBuffer.append(fromClause);
sqlBuffer.append(' ');
sqlBuffer.append(whereClause);
-
+
if (f.getOrder() != null && !f.getOrder().equals(""))
{
orderClause = " ORDER BY "+f.getOrder();
@@ -163,7 +163,7 @@
return parameterArray;
}
- /** 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.
@@ -207,7 +207,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());
@@ -215,7 +215,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)
@@ -227,7 +227,7 @@
}
i++;
}
-
+
//Ok, build a new order string that we can use later on
StringBuffer orderTokensToUse = new StringBuffer("");
i = 0;
@@ -244,7 +244,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