From 56ae0ae6ae48cd07156cb6c9e4048ad62df823cd Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Wed, 8 Jul 2009 20:01:08 +0000 Subject: [PATCH] OPENJPA-525 - Semi-revert the original solution due to regression in ResultSetResult.translate() method. Implemented an alternative solution to perform the same original intent. Based on Milosz, the current solution caused some failure in MySQL. He agreed for this interim commit and look for cause of failures in MySQL. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@792284 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/openjpa/jdbc/sql/AbstractResult.java | 9 ++++++--- .../apache/openjpa/jdbc/sql/ResultSetResult.java | 13 ++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) 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)); }