Author: hthomann
Date: Mon Aug 12 21:58:31 2013
New Revision: 1513275
URL: http://svn.apache.org/r1513275
Log:
OPENJPA-2376: Escape character in JPQL with parameter substitution generates
incorrect SQL - committed a patch sent to me by Albert Lee - merged changes
from 2.1.x.
Added:
openjpa/branches/2.2.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
- copied unchanged from r1513249,
openjpa/branches/2.1.x/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/kernel/TestSQLStoreParamsSubstitution.java
Modified:
openjpa/branches/2.2.x/ (props changed)
openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
Propchange: openjpa/branches/2.2.x/
------------------------------------------------------------------------------
Merged /openjpa/branches/2.1.x:r1513249
Modified:
openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java?rev=1513275&r1=1513274&r2=1513275&view=diff
==============================================================================
---
openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
(original)
+++
openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SQLStoreQuery.java
Mon Aug 12 21:58:31 2013
@@ -365,6 +365,7 @@ public class SQLStoreQuery
if (sql.indexOf("?") == -1)
return sql;
+ sql = sql.replaceAll("\\\\", "\\\\\\\\");
paramOrder.clear();
StreamTokenizer tok = new StreamTokenizer(new StringReader(sql));
tok.resetSyntax();
@@ -396,6 +397,14 @@ public class SQLStoreQuery
buf.append(tok.sval);
buf.append('\'');
}
+// // StreamTokenizer can not differentiate the last
quoted token as in ^.*'.*$ and ^.*',*'$
+// // need to check the last quote ends with "'" and
process accordingly.
+// if(endsWithQuote) {
+// buf.append('\'');
+// } else if (tok.nextToken() !=
StreamTokenizer.TT_EOF) {
+// tok.pushBack();
+// buf.append('\'');
+// }
break;
default:
buf.append((char) ttype);