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
This commit is contained in:
Albert Lee 2009-07-08 20:01:08 +00:00
parent 717a0b1855
commit 56ae0ae6ae
2 changed files with 12 additions and 10 deletions

View File

@ -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));

View File

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