diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractResult.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractResult.java index 6e6f3edfe..ad2ec2e9c 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractResult.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractResult.java @@ -30,6 +30,7 @@ import java.sql.Ref; import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; +import java.sql.Types; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -756,15 +757,17 @@ public abstract class AbstractResult public String getString(Object obj) throws SQLException { - return getStringInternal(translate(obj, null), null); + return getStringInternal(translate(obj, null), null, + obj instanceof Column && ((Column) obj).getType() == Types.CLOB); } public String getString(Column col, Joins joins) throws SQLException { - return getStringInternal(translate(col, joins), joins); + return getStringInternal(translate(col, joins), joins, + col.getType() == Types.CLOB); } - protected String getStringInternal(Object obj, Joins joins) + protected String getStringInternal(Object obj, Joins joins, boolean isClobString) throws SQLException { Object val = checkNull(getObjectInternal(obj, JavaTypes.STRING, null, joins)); diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ResultSetResult.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ResultSetResult.java index 528439ff7..240cbf8c2 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ResultSetResult.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ResultSetResult.java @@ -393,7 +393,8 @@ public class ResultSetResult val = new Short(getShortInternal(obj, joins)); break; case JavaTypes.STRING: - return getStringInternal(obj, joins); + return getStringInternal(obj, joins, + obj instanceof Column && ((Column) obj).getType() == Types.CLOB); case JavaTypes.OBJECT: return _dict .getBlobObject(_rs, ((Number) obj).intValue(), _store); @@ -462,10 +463,11 @@ public class ResultSetResult return _dict.getShort(_rs, ((Number) obj).intValue()); } - protected String getStringInternal(Object obj, Joins joins) + protected String getStringInternal(Object obj, Joins joins, boolean isClobString) throws SQLException { - if (obj instanceof Column && ((Column) obj).getType() == Types.CLOB) - return _dict.getClobString(_rs, findObject(obj, joins)); + if (isClobString) { + return _dict.getClobString(_rs, ((Number) obj).intValue()); + } return _dict.getString(_rs, ((Number) obj).intValue()); } @@ -489,9 +491,6 @@ public class ResultSetResult throws SQLException { if (obj instanceof Number) return obj; - // getStringInternal will take care the translation - if (obj instanceof Column && ((Column) obj).getType() == Types.CLOB) - return obj; return Numbers.valueOf(findObject(obj, joins)); }