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