From 52d7ab797565c7b182a87128eb0a484a7e9237a7 Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Tue, 21 Aug 2007 05:26:15 +0000 Subject: [PATCH] OPENJPA-321. Avoiding JDK1.5-specific String.replace() call. Also changed the method to return a well-balanced SQL, since it looks like the only usage is in a place where well-balanced-ness is possible. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@567962 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java index f7f08100a..d3a088d93 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java @@ -37,6 +37,7 @@ import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.meta.JavaTypes; import org.apache.openjpa.util.OpenJPAException; import org.apache.openjpa.util.UnsupportedException; +import serp.util.Strings; /** * Dictionary for IBM DB2 database. @@ -630,7 +631,8 @@ public class DB2Dictionary String asString) { String fstring = func; if (func.indexOf(target) != -1) - fstring = func.replace(target, "CAST(" + target + asString); + fstring = Strings.replace( + func, target, "CAST(" + target + asString + ")"); return fstring; } @@ -659,7 +661,7 @@ public class DB2Dictionary public String getCastFunction(Val val, String func) { if (val instanceof Lit || val instanceof Param) if (func.indexOf("VARCHAR") == -1) - func = addCastAsString(func, "{0}", " AS VARCHAR(1000))"); + func = addCastAsString(func, "{0}", " AS VARCHAR(1000)"); return func; }