mirror of https://github.com/apache/openjpa.git
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
This commit is contained in:
parent
eaeebf20c7
commit
52d7ab7975
|
@ -37,6 +37,7 @@ import org.apache.openjpa.lib.util.Localizer;
|
||||||
import org.apache.openjpa.meta.JavaTypes;
|
import org.apache.openjpa.meta.JavaTypes;
|
||||||
import org.apache.openjpa.util.OpenJPAException;
|
import org.apache.openjpa.util.OpenJPAException;
|
||||||
import org.apache.openjpa.util.UnsupportedException;
|
import org.apache.openjpa.util.UnsupportedException;
|
||||||
|
import serp.util.Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dictionary for IBM DB2 database.
|
* Dictionary for IBM DB2 database.
|
||||||
|
@ -630,7 +631,8 @@ public class DB2Dictionary
|
||||||
String asString) {
|
String asString) {
|
||||||
String fstring = func;
|
String fstring = func;
|
||||||
if (func.indexOf(target) != -1)
|
if (func.indexOf(target) != -1)
|
||||||
fstring = func.replace(target, "CAST(" + target + asString);
|
fstring = Strings.replace(
|
||||||
|
func, target, "CAST(" + target + asString + ")");
|
||||||
return fstring;
|
return fstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +661,7 @@ public class DB2Dictionary
|
||||||
public String getCastFunction(Val val, String func) {
|
public String getCastFunction(Val val, String func) {
|
||||||
if (val instanceof Lit || val instanceof Param)
|
if (val instanceof Lit || val instanceof Param)
|
||||||
if (func.indexOf("VARCHAR") == -1)
|
if (func.indexOf("VARCHAR") == -1)
|
||||||
func = addCastAsString(func, "{0}", " AS VARCHAR(1000))");
|
func = addCastAsString(func, "{0}", " AS VARCHAR(1000)");
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue