mirror of
https://github.com/apache/openjpa.git
synced 2025-02-08 11:06:01 +00:00
OPENJPA-2242 - Extends procedure call parameter String cast length if value length is greater than the default length
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1371268 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ebe6c7ca5
commit
17ecb7a338
@ -219,7 +219,7 @@ public class DB2Dictionary
|
|||||||
// if the literal is a string, use the default char col size
|
// if the literal is a string, use the default char col size
|
||||||
// in the cast statement.
|
// in the cast statement.
|
||||||
if (String.class.equals(c))
|
if (String.class.equals(c))
|
||||||
selectSQL.append("(" + characterColumnSize + ")");
|
selectSQL.append("(" + getCastStringColumnSize(val) + ")");
|
||||||
|
|
||||||
selectSQL.append(")");
|
selectSQL.append(")");
|
||||||
}
|
}
|
||||||
@ -799,7 +799,7 @@ public class DB2Dictionary
|
|||||||
String type = getTypeName(getJDBCType(JavaTypes.getTypeCode(val
|
String type = getTypeName(getJDBCType(JavaTypes.getTypeCode(val
|
||||||
.getType()), false));
|
.getType()), false));
|
||||||
if (String.class.equals(val.getType()))
|
if (String.class.equals(val.getType()))
|
||||||
type = type + "(" + characterColumnSize + ")";
|
type = type + "(" + getCastStringColumnSize(val) + ")";
|
||||||
fstring = "CAST(? AS " + type + ")";
|
fstring = "CAST(? AS " + type + ")";
|
||||||
return fstring;
|
return fstring;
|
||||||
}
|
}
|
||||||
@ -927,7 +927,7 @@ public class DB2Dictionary
|
|||||||
// case "(?" - convert to "CAST(? AS type"
|
// case "(?" - convert to "CAST(? AS type"
|
||||||
String typeName = getTypeName(type);
|
String typeName = getTypeName(type);
|
||||||
if (String.class.equals(val.getType()))
|
if (String.class.equals(val.getType()))
|
||||||
typeName = typeName + "(" + characterColumnSize + ")";
|
typeName = typeName + "(" + getCastStringColumnSize(val) + ")";
|
||||||
String str = "CAST(? AS " + typeName + ")";
|
String str = "CAST(? AS " + typeName + ")";
|
||||||
buf.replaceSqlString(sqlString.length() - 1,
|
buf.replaceSqlString(sqlString.length() - 1,
|
||||||
sqlString.length(), str);
|
sqlString.length(), str);
|
||||||
@ -1076,6 +1076,20 @@ public class DB2Dictionary
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getCastStringColumnSize(Object val) {
|
||||||
|
int colSize = characterColumnSize;
|
||||||
|
if (val instanceof Lit) {
|
||||||
|
String literal = (String) ((Lit) val).getValue();
|
||||||
|
if (literal != null) {
|
||||||
|
int literalLen = literal.length();
|
||||||
|
if (literalLen > characterColumnSize) {
|
||||||
|
colSize = literalLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colSize;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertBlobForStreamingLoad(Row row, Column col,
|
public void insertBlobForStreamingLoad(Row row, Column col,
|
||||||
JDBCStore store, Object ob, Select sel) throws SQLException {
|
JDBCStore store, Object ob, Select sel) throws SQLException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user